File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -90,10 +90,14 @@ let s:end_skip_expr = s:skip_expr .
9090let s: non_bracket_continuation_regex = ' \%([\\.,:*/%+]\|\<and\|\<or\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$'
9191
9292" Regex that defines continuation lines.
93- " TODO: this needs to deal with if ...: and so on
9493let s: continuation_regex =
9594 \ ' \%(%\@<![({[\\.,:*/%+]\|\<and\|\<or\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$'
9695
96+ " Regex that defines continuable keywords
97+ let s: continuable_regex =
98+ \ ' \C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' .
99+ \ ' \<\%(if\|for\|while\|until\|unless\):\@!\>'
100+
97101" Regex that defines bracket continuations
98102let s: bracket_continuation_regex = ' %\@<!\%([({[]\)\s*\%(#.*\)\=$'
99103
@@ -488,6 +492,10 @@ function GetRubyIndent(...)
488492 endif
489493 endif
490494
495+ if s: Match (lnum, s: continuable_regex ) && s: Match (lnum, s: continuation_regex )
496+ return indent (s: GetMSL (lnum)) + &sw + &sw
497+ endif
498+
491499 " If the previous line ended with a block opening, add a level of indent.
492500 if s: Match (lnum, s: block_regex )
493501 return indent (s: GetMSL (lnum)) + &sw
Original file line number Diff line number Diff line change @@ -176,4 +176,16 @@ def bar(
176176 'b'
177177 EOF
178178 end
179+
180+ specify "continuation with if" do
181+ # See https://github.com/vim-ruby/vim-ruby/issues/215 for details
182+ assert_correct_indenting <<-EOF
183+ if foo || bar ||
184+ bong &&
185+ baz || bing
186+ puts "foo"
187+ end
188+ EOF
189+ end
190+
179191end
You can’t perform that action at this time.
0 commit comments