@@ -41,6 +41,9 @@ let s:syng_string = 'regex\c'
4141" Regex of syntax group names that are strings or documentation.
4242let s: syng_multiline = ' comment\c'
4343
44+ " Regex of syntax group names that are line comment.
45+ let s: syng_linecom = ' linecomment'
46+
4447" Expression used to check whether we should skip a match with searchpair().
4548let s: skip_expr = " synIDattr(synID(line('.'),col('.'),1),'name') =~ '" .s: syng_strcom ." '"
4649
@@ -76,6 +79,11 @@ function s:IsInMultilineComment(lnum, col)
7679 return synIDattr (synID (a: lnum , a: col , 1 ), ' name' ) = ~ s: syng_multiline
7780endfunction
7881
82+ " Check if the character at lnum:col is a line comment.
83+ function s: IsLineComment (lnum, col )
84+ return synIDattr (synID (a: lnum , a: col , 1 ), ' name' ) = ~ s: syng_linecom
85+ endfunction
86+
7987" Find line above 'lnum' that isn't empty, in a comment, or in a string.
8088function s: PrevNonBlankNonString (lnum)
8189 let in_block = 0
@@ -244,7 +252,7 @@ function GetJavascriptIndent()
244252 endif
245253
246254 " If we are in a multi-line comment, cindent does the right thing.
247- if s: IsInMultilineComment (v: lnum , 1 )
255+ if s: IsInMultilineComment (v: lnum , 1 ) && ! s: IsLineComment ( v: lnum , 1 )
248256 return cindent (v: lnum )
249257 endif
250258
0 commit comments