File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ let s:comma_last = ',\s*$'
67
67
68
68
let s: ternary = ' ^\s\+[?|:]'
69
69
let s: ternary_q = ' ^\s\+?'
70
+ let s: ternary_s = ' ^\s\+:'
70
71
71
72
let s: case_indent = &sw
72
73
let s: case_indent_after = &sw
@@ -367,13 +368,19 @@ function GetJavascriptIndent()
367
368
return indent (prevline) + s: case_indent_after
368
369
endif
369
370
371
+ " If in a multi line ternary, indent the next line
370
372
if (line = ~ s: ternary )
371
373
if (getline (prevline) = ~ s: ternary_q )
372
374
return indent (prevline)
373
375
else
374
376
return indent (prevline) + &sw
375
377
endif
376
378
endif
379
+ " If the previous line was the last part of a multiline ternary, dedent
380
+ if (getline (prevline) = ~ s: ternary_s )
381
+ return indent (prevline) - &sw
382
+ endif
383
+
377
384
378
385
" If we are in a multi-line comment, cindent does the right thing.
379
386
if s: IsInMultilineComment (v: lnum , 1 ) && ! s: IsLineComment (v: lnum , 1 )
You can’t perform that action at this time.
0 commit comments