Skip to content

Commit e948812

Browse files
bouncemebounceme
bounceme
authored and
bounceme
committed
final
1 parent 539f267 commit e948812

File tree

1 file changed

+20
-31
lines changed

1 file changed

+20
-31
lines changed

indent/javascript.vim

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -148,34 +148,24 @@ function s:GetMSL(lnum, in_one_line_scope)
148148
" Otherwise, terminate search as we have found our MSL already.
149149
let line = getline(lnum)
150150
let col = match(line, s:msl_regex) + 1
151-
let colprev = s:Match(msl, s:operator_first)
152-
if ((col > 0 && !s:IsInStringOrComment(lnum, col)) || s:IsInString(lnum, strlen(line)) || colprev)
151+
if (col > 0 && !s:IsInStringOrComment(lnum, col)) || s:IsInString(lnum, strlen(line))
153152
let msl = lnum
154-
else
155-
" Don't use lines that are part of a one line scope as msl unless the
156-
" flag in_one_line_scope is set to 1
157-
"
158-
if a:in_one_line_scope
159-
break
160-
end
161-
let msl_one_line = s:Match(lnum, s:one_line_scope_regex)
162-
if msl_one_line == 0
163-
break
164-
endif
165-
endif
166-
let coli = matchend(line, '^\s*[]})]')
167-
if coli
168-
let bs = strpart('(){}[]', stridx(')}]', line[coli - 1]) * 2, 2)
169-
let mnum = searchpair(escape(bs[0], '\['), '', bs[1], 'bW', s:skip_expr) > 0
170-
if mnum
171-
let lnum = mnum
172-
end
153+
else
154+
" Don't use lines that are part of a one line scope as msl unless the
155+
" flag in_one_line_scope is set to 1
156+
"
157+
if a:in_one_line_scope
158+
break
173159
end
174-
175-
let lnum = s:PrevNonBlankNonString(lnum - 1)
176-
endwhile
177-
return msl
178-
endfunction
160+
let msl_one_line = s:Match(lnum, s:one_line_scope_regex)
161+
if msl_one_line == 0
162+
break
163+
endif
164+
endif
165+
let lnum = s:PrevNonBlankNonString(lnum - 1)
166+
endwhile
167+
return msl
168+
endfunction
179169

180170
function s:RemoveTrailingComments(content)
181171
let single = '\/\/\(.*\)\s*$'
@@ -411,13 +401,12 @@ function GetJavascriptIndent()
411401
return indent(prevline) + s:sw()
412402
end
413403
" If previous line starts with a operator...
414-
elseif (s:Match(prevline, s:operator_first) || s:Match(v:lnum, '^\s*[)}]'))
415-
let counts = s:LineHasOpeningBrackets(prevline)
416-
if counts[0] != '1' && counts[1] != '1' && counts[2] != '1'
417-
" dedent 1 level
404+
elseif s:Match(prevline, s:operator_first) && !s:Match(prevline, s:comma_last)
405+
let countscur = s:LineHasOpeningBrackets(v:lnum)
406+
if countscur[0] != '2'
418407
return indent(prevline) - s:sw()
419408
end
420-
endif
409+
end
421410

422411
" If we are in a multi-line comment, cindent does the right thing.
423412
if s:IsInMultilineComment(v:lnum, 1) && !s:IsLineComment(v:lnum, 1)

0 commit comments

Comments
 (0)