Skip to content

Commit 77c4ae6

Browse files
authored
better line cleaning (#649)
1 parent d6b2fd5 commit 77c4ae6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

indent/javascript.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ if !exists('g:javascript_continuation')
7575
endif
7676

7777
let g:javascript_opfirst = '^' . g:javascript_opfirst
78-
let g:javascript_continuation .= s:line_term
78+
let g:javascript_continuation .= '$'
7979

8080
function s:OneScope(lnum,text)
8181
return cursor(a:lnum, match(' ' . a:text, '\%(\<else\|\<do\|=>\)' . s:line_term)) > -1 ||
@@ -215,15 +215,15 @@ function GetJavascriptIndent()
215215
endif
216216

217217
let s:W = s:sw()
218-
let pline = substitute(substitute(getline(l:lnum),s:expr_case,'\=repeat(" ",strlen(submatch(0)))',''), ':\@<!\/\/.*', '','')
218+
let pline = substitute(substitute(getline(l:lnum),':\@<!\/\/.*','',''), s:line_term, '','')
219219
call cursor(b:js_cache[1],b:js_cache[2])
220220
let switch_offset = !num || !(search(')\_s*\%#','bW') &&
221221
\ s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0 && search('\C\<switch\_s*\%#','bW')) ? 0 :
222222
\ &cino !~ ':' || !has('float') ? s:W :
223223
\ float2nr(str2float(matchstr(&cino,'.*:\zs[-0-9.]*')) * (&cino =~# '.*:[^,]*s' ? s:W : 1))
224224

225225
" most significant, find the indent amount
226-
let isOp = l:line =~# g:javascript_opfirst || pline =~# g:javascript_continuation
226+
let isOp = l:line =~# g:javascript_opfirst || pline !~# s:expr_case . '$' && pline =~# g:javascript_continuation
227227
let bL = s:iscontOne(l:lnum,num,isOp)
228228
let bL -= (bL && l:line =~ '^{') * s:W
229229
if isOp && (!num || cursor(b:js_cache[1],b:js_cache[2]) || s:IsBlock())

0 commit comments

Comments
 (0)