@@ -71,24 +71,23 @@ let g:javascript_continuation .= s:line_term
7171
7272function s: Onescope (lnum,text,add )
7373 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 ) ||
7475 \ (cursor (a: lnum , match (a: text , ' )' . s: line_term )) > -1 &&
7576 \ 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' )) &&
7979 \ (a: add || (expand (" <cword>" ) == ' while' ? ! s: lookForParens (' \<do\>\C' , ' \<while\>\C' ,' bW' ,100 ) : 1 ))
8080endfunction
8181
8282" Auxiliary Functions {{{2
83- " ======================
8483
8584" Check if the character at lnum:col is inside a string, comment, or is ascii.
8685function s: IsSyn (lnum, col , reg )
8786 return synIDattr (synID (a: lnum , a: col , 1 ), ' name' ) = ~? (a: reg != ' ' ? a: reg : s: syng_strcom )
8887endfunction
8988
9089" 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)
9291 let lnum = prevnonblank (a: lnum )
9392 while lnum > 0
9493 if ! s: IsSyn (lnum, matchend (getline (lnum), ' ^\s*[^'' "]' ),' ' )
@@ -133,7 +132,7 @@ function GetJavascriptIndent()
133132 " previous nonblank line number
134133 let prevline = prevnonblank (v: lnum - 1 )
135134 " previous line of code
136- let lnum = s: PrevNonBlankNonString (v: lnum - 1 )
135+ let lnum = s: PrevCodeLine (v: lnum - 1 )
137136 if lnum == 0
138137 return 0
139138 endif
0 commit comments