@@ -71,11 +71,11 @@ 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 ) ||
75
- \ ( cursor (a: lnum , match (a: text , ' )' . s: line_term )) > -1 &&
74
+ \ (( a: add && a: text = ~ s: line_pre . s: line_term && search ( ' \% ' . s: PrevCodeLine (a: lnum - 1 ) . ' l. )' . s: line_term) ) ||
75
+ \ cursor (a: lnum , match (a: text , ' )' . s: line_term )) > -1 ) &&
76
76
\ s: lookForParens (' (' , ' )' , ' cbW' , 100 ) > 0 &&
77
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' ) ) &&
78
+ \ ' \<\%(for\%(\s+each\)\=\|if\|let\|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
@@ -132,10 +132,6 @@ function GetJavascriptIndent()
132
132
" previous nonblank line number
133
133
let prevline = prevnonblank (v: lnum - 1 )
134
134
" previous line of code
135
- let lnum = s: PrevCodeLine (v: lnum - 1 )
136
- if lnum == 0
137
- return 0
138
- endif
139
135
140
136
" start with strings,comments,etc.{{{2
141
137
if (line !~ ' ^['' "`]' && s: IsSyn (v: lnum ,1 ,' string\|template' )) ||
@@ -145,6 +141,10 @@ function GetJavascriptIndent()
145
141
if line !~ ' ^\%(\/\*\|\s*\/\/\)' && s: IsSyn (v: lnum ,1 ,s: syng_comment )
146
142
return cindent (v: lnum )
147
143
endif
144
+ let lnum = s: PrevCodeLine (v: lnum - 1 )
145
+ if lnum == 0
146
+ return 0
147
+ endif
148
148
149
149
if (line = ~ s: expr_case )
150
150
let cpo_switch = &cpo
0 commit comments