@@ -71,24 +71,23 @@ let g:javascript_continuation .= s:line_term
71
71
72
72
function s: Onescope (lnum,text,add )
73
73
return a: text = ~ ' \%(\<else\|\<do\|=>' . (a: add ? ' \|\<try\|\<finally' : ' ' ) . ' \)\C' . s: line_term ||
74
+ \ (a: add && a: text = ~ s: line_pre . s: line_term && getline (s: PrevCodeLine (a: lnum - 1 )) = ~ ' )' . s: line_term ) ||
74
75
\ (cursor (a: lnum , match (a: text , ' )' . s: line_term )) > -1 &&
75
76
\ s: lookForParens (' (' , ' )' , ' cbW' , 100 ) > 0 &&
76
- \ search ((a: add ? ' \K\k*' :
77
- \ ' \<\%(for\%(\s+each\)\=\|function\*\=\%(\s\+\K\k*\)\=\|if\|let\|switch\|while\|with\)\C' ) .
78
- \ ' \_s*\%#' ,' bW' )) &&
77
+ \ search ((a: add ? ' \%(function\*\|[A-Za-z_$][0-9A-Za-z_$]*\)\C' :
78
+ \ ' \<\%(for\%(\s+each\)\=\|if\|let\|switch\|while\|with\)\C' ) . ' \_s*\%#' ,' bW' )) &&
79
79
\ (a: add || (expand (" <cword>" ) == ' while' ? ! s: lookForParens (' \<do\>\C' , ' \<while\>\C' ,' bW' ,100 ) : 1 ))
80
80
endfunction
81
81
82
82
" Auxiliary Functions {{{2
83
- " ======================
84
83
85
84
" Check if the character at lnum:col is inside a string, comment, or is ascii.
86
85
function s: IsSyn (lnum, col , reg )
87
86
return synIDattr (synID (a: lnum , a: col , 1 ), ' name' ) = ~? (a: reg != ' ' ? a: reg : s: syng_strcom )
88
87
endfunction
89
88
90
89
" Find line above 'lnum' that isn't empty, in a comment, or in a string.
91
- function s: PrevNonBlankNonString (lnum)
90
+ function s: PrevCodeLine (lnum)
92
91
let lnum = prevnonblank (a: lnum )
93
92
while lnum > 0
94
93
if ! s: IsSyn (lnum, matchend (getline (lnum), ' ^\s*[^'' "]' ),' ' )
@@ -133,7 +132,7 @@ function GetJavascriptIndent()
133
132
" previous nonblank line number
134
133
let prevline = prevnonblank (v: lnum - 1 )
135
134
" previous line of code
136
- let lnum = s: PrevNonBlankNonString (v: lnum - 1 )
135
+ let lnum = s: PrevCodeLine (v: lnum - 1 )
137
136
if lnum == 0
138
137
return 0
139
138
endif
0 commit comments