@@ -65,10 +65,6 @@ let s:line_term = '\s*\%(\%(\/\/\).*\)\=$'
65
65
" Regex that defines continuation lines, not including (, {, or [.
66
66
let s: continuation_regex = ' \%([\\*/.:]\|+\@<!+\|-\@<!-\|\%(<%\)\@<!=\|\W[|&?]\|||\|&&\|[^=]=[^=>].*,\)' . s: line_term
67
67
68
- " Regex that defines continuation lines.
69
- " TODO: this needs to deal with if ...: and so on
70
- let s: msl_regex = s: continuation_regex .' \|' .s: expr_case
71
-
72
68
let s: one_line_scope_regex = ' \%(\%(\<else\>\|\<\%(if\|for\|while\)\>\s*(\%([^()]*\|[^()]*(\%([^()]*\|[^()]*(\%([^()]*\|[^()]*([^()]*)[^()]*\))[^()]*\))[^()]*\))\)\|=>\)' . s: line_term
73
69
74
70
" Regex that defines blocks.
@@ -81,16 +77,6 @@ let s:var_stmt = '^\s*\%(const\|let\|var\)'
81
77
let s: comma_first = ' ^\s*,'
82
78
let s: comma_last = ' ,\s*$'
83
79
84
- let s: case_indent = s: sw ()
85
- let s: case_indent_after = s: sw ()
86
- let s: m = matchlist (&cinoptions , ' :\(.\)' )
87
- if (len (s: m ) > 2 )
88
- let s: case_indent = s: m [1 ]
89
- endif
90
- let s: m = matchlist (&cinoptions , ' =\(.\)' )
91
- if (len (s: m ) > 2 )
92
- let s: case_indent_after = s: m [1 ]
93
- endif
94
80
" 2. Auxiliary Functions {{{1
95
81
" ======================
96
82
@@ -152,10 +138,10 @@ function s:GetMSL(lnum, in_one_line_scope)
152
138
" If we have a continuation line, or we're in a string, use line as MSL.
153
139
" Otherwise, terminate search as we have found our MSL already.
154
140
let line = getline (lnum)
155
- let col = match (line , s: msl_regex ) + 1
141
+ let col = match (line , s: continuation_regex ) + 1
156
142
let line2 = getline (msl)
157
143
let col2 = matchend (line2, ' )' )
158
- if (col > 0 && ! s: IsInStringOrComment (lnum, col )) || s: IsInString (lnum, strlen (line ))
144
+ if (col > 0 && ! s: IsInStringOrComment (lnum, col ) && ! s: Match (lnum, s: expr_case ) ) || s: IsInString (lnum, strlen (line ))
159
145
let msl = lnum
160
146
161
147
" if there are more closing brackets, continue from the line which has the matching opening bracket
@@ -327,7 +313,6 @@ endfunction
327
313
function GetJavascriptIndent ()
328
314
" 3.1. Setup {{{2
329
315
" ----------
330
-
331
316
" Set up variables for restoring position in file. Could use v:lnum here.
332
317
let vcol = col (' .' )
333
318
@@ -341,15 +326,7 @@ function GetJavascriptIndent()
341
326
let prevline = prevnonblank (v: lnum - 1 )
342
327
343
328
if (line = ~ s: expr_case )
344
- if (getline (prevline) = ~ s: expr_case )
345
- return indent (prevline)
346
- else
347
- if (getline (prevline) = ~ s: block_regex )
348
- return indent (prevline) + s: case_indent
349
- else
350
- return indent (prevline) - s: case_indent_after
351
- endif
352
- endif
329
+ return cindent (v: lnum )
353
330
endif
354
331
" If we got a closing bracket on an empty line, find its match and indent
355
332
" according to it. For parentheses we indent to its column - 1, for the
@@ -393,9 +370,6 @@ function GetJavascriptIndent()
393
370
if (getline (prevline) = ~ s: comma_first )
394
371
return indent (prevline) - s: sw ()
395
372
endif
396
- if (getline (prevline) = ~ s: expr_case )
397
- return indent (prevline) + s: case_indent_after
398
- endif
399
373
400
374
" If line starts with an operator...
401
375
if (s: Match (v: lnum , s: operator_first ))
@@ -475,11 +449,7 @@ function GetJavascriptIndent()
475
449
476
450
" If the previous line ended with a block opening, add a level of indent.
477
451
if s: Match (lnum, s: block_regex )
478
- if (line = ~ s: expr_case )
479
- return indent (s: GetMSL (lnum, 0 )) + s: sw ()/2
480
- else
481
- return indent (s: GetMSL (lnum, 0 )) + s: sw ()
482
- endif
452
+ return indent (s: GetMSL (lnum, 0 )) + s: sw ()
483
453
endif
484
454
485
455
" Set up variables for current line.
0 commit comments