We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 790e095 commit 85eeb98Copy full SHA for 85eeb98
1 file changed
indent/javascript.vim
@@ -64,6 +64,8 @@ let s:var_stmt = '^\s*var'
64
let s:comma_first = '^\s*,'
65
let s:comma_last = ',\s*$'
66
67
+let s:ternary = '^\s\+[?|:]'
68
+
69
" 2. Auxiliary Functions {{{1
70
" ======================
71
@@ -339,6 +341,14 @@ function GetJavascriptIndent()
339
341
return indent(prevline) - &sw
340
342
endif
343
344
+ if (line =~ s:ternary)
345
+ if (getline(prevline) =~ s:ternary)
346
+ return indent(prevline)
347
+ else
348
+ return indent(prevline) + &sw
349
+ endif
350
351
352
" If we are in a multi-line comment, cindent does the right thing.
353
if s:IsInMultilineComment(v:lnum, 1) && !s:IsLineComment(v:lnum, 1)
354
return cindent(v:lnum)
0 commit comments