Skip to content

Commit 9bc0eb1

Browse files
committed
Fix indentation after multi-line comments.
Closes pangloss#28.
1 parent 5267b4f commit 9bc0eb1

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

indent/javascript.vim

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,19 @@ function GetJavascriptIndent()
251251
" 3.3. Work on the previous line. {{{2
252252
" -------------------------------
253253

254+
" If the line is empty and the previous nonblank line was a multi-line
255+
" comment, use that comment's indent. Deduct one char to account for the
256+
" space in ' */'.
257+
let nonblank_lnum = prevnonblank(v:lnum - 1)
258+
if line =~ '^\s*$' && s:IsInMultilineComment(nonblank_lnum, 1)
259+
return indent(nonblank_lnum) - 1
260+
endif
261+
254262
" Find a non-blank, non-multi-line string line above the current line.
255263
let lnum = s:PrevNonBlankNonString(v:lnum - 1)
256264

257265
" If the line is empty and inside a string, use the previous line.
258-
if line =~ '^\s*$' && lnum != prevnonblank(v:lnum - 1)
266+
if line =~ '^\s*$' && lnum != nonblank_lnum
259267
return indent(prevnonblank(v:lnum))
260268
endif
261269

0 commit comments

Comments
 (0)