Skip to content

Commit

Permalink
Merge pull request #290 from fenoloftaleina/master
Browse files Browse the repository at this point in the history
Match much more complicated structures in block's arguments in a very simple way.
  • Loading branch information
tpope committed Feb 12, 2016
2 parents cc6fb0f + c160335 commit 666adb5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion indent/ruby.vim
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ let s:indent_access_modifier_regex = '\C^\s*\%(protected\|private\)\s*\%(#.*\)\=
" The reason is that the pipe matches a hanging "|" operator.
"
let s:block_regex =
\ '\%(\<do:\@!\>\|%\@<!{\)\s*\%(|\s*(*\s*\%([*@&]\=\h\w*,\=\s*\)\%(,\s*(*\s*[*@&]\=\h\w*\s*)*\s*\)*|\)\=\s*\%(#.*\)\=$'
\ '\%(\<do:\@!\>\|%\@<!{\)\s*\%(|[^|]*|\)\=\s*\%(#.*\)\=$'

let s:block_continuation_regex = '^\s*[^])}\t ].*'.s:block_regex

Expand Down
14 changes: 14 additions & 0 deletions spec/indent/blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,18 @@ module X
end
EOF
end

specify "blocks with default arguments" do
assert_correct_indenting <<-EOF
proc do |a = 1|
puts a
end
EOF

assert_correct_indenting <<-EOF
proc do |a: "asdf", b:|
puts a, b
end
EOF
end
end

0 comments on commit 666adb5

Please sign in to comment.