Skip to content

Commit a9073e5

Browse files
committed
Restrict "do" blocks a bit
This solves the problem of a "do" being detected where it's part of a method call or a symbol. See: vim-ruby#92
1 parent 34a0862 commit a9073e5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

etc/examples/indent/blocks.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
do
2+
something
3+
end
4+
5+
def foo
6+
a_hash = {:do => 'bar'}
7+
end
8+
9+
def foo(job)
10+
job.do!
11+
end
12+
113
proc do |(a, b)|
214
puts a
315
puts b

indent/ruby.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ let s:ruby_deindent_keywords =
6666
let s:end_start_regex =
6767
\ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' .
6868
\ '\<\%(module\|class\|def\|if\|for\|while\|until\|case\|unless\|begin\):\@!\>' .
69-
\ '\|\<do:\@!\>'
69+
\ '\|\%(^\|[^.:@$]\)\@<=\<do:\@!\>'
7070

7171
" Regex that defines the middle-match for the 'end' keyword.
7272
let s:end_middle_regex = '\<\%(ensure\|else\|\%(\%(^\|;\)\s*\)\@<=\<rescue:\@!\>\|when\|elsif\):\@!\>'

0 commit comments

Comments
 (0)