@@ -76,7 +76,7 @@ let s:var_stmt = '^\s*(const\|let\|var)'
76
76
let s: comma_first = ' ^\s*,'
77
77
let s: comma_last = ' ,\s*$'
78
78
79
- let s: operator_first = ' ^\s*\%([* +.:?]\|||\|&&\)'
79
+ let s: operator_first = ' ^\s*\%([-*/ +.:?]\|||\|&&\)'
80
80
81
81
let s: case_indent = s: sw ()
82
82
let s: case_indent_after = s: sw ()
@@ -377,9 +377,8 @@ function GetJavascriptIndent()
377
377
return indent (prevline) + s: case_indent_after
378
378
endif
379
379
380
- " If line starts with operator...
381
- if (line = ~ s: operator_first )
382
- if (getline (prevline) = ~ s: operator_first )
380
+ if (s: Match (v: lnum , s: operator_first ))
381
+ if (s: Match (prevline, s: operator_first ))
383
382
" and so does previous line, don't indent
384
383
return indent (prevline)
385
384
end
@@ -388,20 +387,20 @@ function GetJavascriptIndent()
388
387
call cursor (prevline, 1 )
389
388
" Search for the opening tag
390
389
let mnum = searchpair (' (' , ' ' , ' )' , ' bW' , s: skip_expr )
391
- if mnum > 0
392
- if getline (mnum) = ~ s: operator_first
393
- return indent (mnum)
394
- end
390
+ if mnum > 0 && s: Match (mnum, s: operator_first )
391
+ return indent (mnum)
395
392
end
396
393
else
397
394
" otherwise, indent 1 level
398
- return indent (prevline) + &sw
395
+ return indent (prevline) + s: sw ()
396
+ end
397
+ " If previous line starts with a operator...
398
+ elseif (s: Match (prevline, s: operator_first ))
399
+ let counts = s: LineHasOpeningBrackets (prevline)
400
+ if counts[0 ] != ' 1' && counts[1 ] != ' 1' && counts[2 ] != ' 1'
401
+ " dedent 1 level
402
+ return indent (prevline) - s: sw ()
399
403
end
400
- end
401
- " If previous line starts with a dot...
402
- if (getline (prevline) = ~ s: operator_first )
403
- " dedent 1 level
404
- return indent (prevline) - &sw
405
404
endif
406
405
407
406
" If we are in a multi-line comment, cindent does the right thing.
0 commit comments