Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion indent/javascript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ let s:syng_string = 'regex\c'
" Regex of syntax group names that are strings or documentation.
let s:syng_multiline = 'comment\c'

" Regex of syntax group names that are line comment.
let s:syng_linecom = 'linecomment\c'

" Expression used to check whether we should skip a match with searchpair().
let s:skip_expr = "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'"

Expand Down Expand Up @@ -76,6 +79,11 @@ function s:IsInMultilineComment(lnum, col)
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_multiline
endfunction

" Check if the character at lnum:col is a line comment.
function s:IsLineComment(lnum, col)
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_linecom
endfunction

" Find line above 'lnum' that isn't empty, in a comment, or in a string.
function s:PrevNonBlankNonString(lnum)
let in_block = 0
Expand Down Expand Up @@ -244,7 +252,7 @@ function GetJavascriptIndent()
endif

" If we are in a multi-line comment, cindent does the right thing.
if s:IsInMultilineComment(v:lnum, 1)
if s:IsInMultilineComment(v:lnum, 1) && !s:IsLineComment(v:lnum, 1)
return cindent(v:lnum)
endif

Expand Down