@@ -65,7 +65,22 @@ 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
- let s: one_line_scope_regex = ' \%(\%(\<else\>\|\<\%(if\|for\|while\)\>\s*(\%([^()]*\|[^()]*(\%([^()]*\|[^()]*(\%([^()]*\|[^()]*([^()]*)[^()]*\))[^()]*\))[^()]*\))\)\|=>\)' . s: line_term
68
+ let s: one_line_scope_regex = ' \%(\<else\>\|=>\)' . s: line_term
69
+
70
+ function s: Onescope (lnum)
71
+ if getline (a: lnum ) = ~ s: one_line_scope_regex
72
+ return 1
73
+ end
74
+ let mypos = col (' .' )
75
+ call cursor (a: lnum , 1 )
76
+ if search (' \<\%(while\|for\|if\)\>\s*(' , ' ce' , a: lnum ) > 0 && searchpair (' (' , ' ' , ' )' , ' W' , s: skip_expr , a: lnum ) > 0 && col (' .' ) + 1 == col (' $' )
77
+ call cursor (a: lnum , mypos)
78
+ return 1
79
+ else
80
+ call cursor (a: lnum , mypos)
81
+ return 0
82
+ end
83
+ endfunction
69
84
70
85
" Regex that defines blocks.
71
86
let s: block_regex = ' \%([{([]\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=' . s: line_term
@@ -160,7 +175,7 @@ function s:GetMSL(lnum, in_one_line_scope)
160
175
if a: in_one_line_scope
161
176
break
162
177
end
163
- let msl_one_line = s: Match (lnum, s: one_line_scope_regex )
178
+ let msl_one_line = s: Onescope (lnum)
164
179
if msl_one_line == 0
165
180
break
166
181
endif
@@ -285,7 +300,7 @@ endfunction
285
300
286
301
function s: InOneLineScope (lnum)
287
302
let msl = s: GetMSL (a: lnum , 1 )
288
- if msl > 0 && s: Match (msl, s: one_line_scope_regex )
303
+ if msl > 0 && s: Onescope (msl)
289
304
return msl
290
305
endif
291
306
return 0
@@ -295,11 +310,11 @@ function s:ExitingOneLineScope(lnum)
295
310
let msl = s: GetMSL (a: lnum , 1 )
296
311
if msl > 0
297
312
" if the current line is in a one line scope ..
298
- if s: Match (msl, s: one_line_scope_regex )
313
+ if s: Onescope (msl)
299
314
return 0
300
315
else
301
316
let prev_msl = s: GetMSL (msl - 1 , 1 )
302
- if s: Match (prev_msl, s: one_line_scope_regex )
317
+ if s: Onescope (prev_msl)
303
318
return prev_msl
304
319
endif
305
320
endif
@@ -472,7 +487,7 @@ function GetJavascriptIndent()
472
487
if line = ~ ' [[({})\]]'
473
488
let counts = s: LineHasOpeningBrackets (lnum)
474
489
if counts[0 ] == ' 1' && searchpair (' (' , ' ' , ' )' , ' bW' , s: skip_expr ) > 0
475
- if col (' .' ) + 1 == col (' $' ) || line = ~ s: one_line_scope_regex
490
+ if col (' .' ) + 1 == col (' $' ) || s: Onescope (lnum)
476
491
return ind + s: sw ()
477
492
else
478
493
return virtcol (' .' )
0 commit comments