Skip to content

Commit dc11766

Browse files
committed
last actual column (#431)
should be considered last non whitespace non comment
1 parent 206b85c commit dc11766

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

indent/javascript.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function s:Onescope(lnum)
7474
end
7575
let mypos = col('.')
7676
call cursor(a:lnum, 1)
77-
if search('\<\%(while\|for\|if\)\>\s*(', 'ce', a:lnum) > 0 && searchpair('(', '', ')', 'W', s:skip_expr, a:lnum) > 0 && col('.') + 1 == col('$')
77+
if search('\<\%(while\|for\|if\)\>\s*(', 'ce', a:lnum) > 0 && searchpair('(', '', ')', 'W', s:skip_expr, a:lnum) > 0 && col('.') == strlen(s:RemoveTrailingComments(getline(a:lnum)))
7878
call cursor(a:lnum, mypos)
7979
return 1
8080
else
@@ -189,7 +189,7 @@ endfunction
189189
function s:RemoveTrailingComments(content)
190190
let single = '\/\/\(.*\)\s*$'
191191
let multi = '\/\*\(.*\)\*\/\s*$'
192-
return substitute(substitute(a:content, single, '', ''), multi, '', '')
192+
return substitute(substitute(substitute(a:content, single, '', ''), multi, '', ''), '\s\+$', '', '')
193193
endfunction
194194

195195
" Find if the string is inside var statement (but not the first string)

0 commit comments

Comments
 (0)