@@ -132,14 +132,14 @@ function GetJavascriptIndent()
132132 " Get the current line.
133133 let line = getline (v: lnum )
134134 " previous nonblank line number
135- let prevline = prevnonblank ( v: lnum - 1 )
135+ let syns = synIDattr ( synID ( v: lnum, 1 , 0 ), ' name ' )
136136
137137 " start with strings,comments,etc.{{{2
138- if (line !~ ' ^['' "`]' && s: IsSyn ( v: lnum , 1 , ' string\|template' ) ) ||
139- \ (line !~ ' ^\s*[/*]' && s: IsSyn ( v: lnum , 1 , s: syng_comment) )
138+ if (line !~ ' ^['' "`]' && syns = ~? ' string\|template' ) ||
139+ \ (line !~ ' ^\s*[/*]' && syns = ~? s: syng_comment )
140140 return -1
141141 endif
142- if line !~ ' ^\%(\/\*\|\s*\/\/\)' && s: IsSyn ( v: lnum , 1 , s: syng_comment)
142+ if line !~ ' ^\%(\/\*\|\s*\/\/\)' && syns = ~? s: syng_comment
143143 return cindent (v: lnum )
144144 endif
145145 let lnum = s: PrevCodeLine (v: lnum - 1 )
@@ -162,8 +162,7 @@ function GetJavascriptIndent()
162162 if b: js_cache [0 ] >= lnum && b: js_cache [0 ] <= v: lnum && b: js_cache [0 ] &&
163163 \ (b: js_cache [0 ] > lnum || s: Balanced (lnum) > 0 )
164164 let num = b: js_cache [1 ]
165- elseif line [0 ] = ~ ' \s'
166- let syns = synIDattr (synID (v: lnum , 1 , 0 ), ' name' )
165+ elseif syns != ' ' && line [0 ] = ~ ' \s'
167166 let pattern = syns = ~? ' block' ? [' {' ,' }' ] : syns = ~? ' jsparen' ? [' (' ,' )' ] :
168167 \ syns = ~? ' jsbracket' ? [' \[' ,' \]' ] : [' [({[]' ,' [])}]' ]
169168 let num = s: lookForParens (pattern[0 ],pattern[1 ],' bW' ,2000 )
0 commit comments