diff --git a/plugin/textobj/rubyblock.vim b/plugin/textobj/rubyblock.vim index e0e5ad1..9e7ecf9 100644 --- a/plugin/textobj/rubyblock.vim +++ b/plugin/textobj/rubyblock.vim @@ -13,7 +13,8 @@ call textobj#user#plugin('rubyblock', { " Misc. "{{{1 let s:comment_escape = '\v^[^#]*' -let s:block_openers = '\zs(||||)' +let s:block_openers = '\zs(||||||' +let s:block_openers .= '||||)' let s:start_pattern = s:comment_escape . s:block_openers let s:end_pattern = s:comment_escape . '\zs' let s:skip_pattern = 'getline(".") =~ "\\v\\S\\s<(if|unless)>\\s\\S"' diff --git a/t/examples.rb b/t/examples.rb index 9dbd0ad..65a88d2 100644 --- a/t/examples.rb +++ b/t/examples.rb @@ -65,3 +65,19 @@ def hello bar end +def method_with_while + var1 = 1 + i = 0 + while i < 10 + i += 1 + end + var2 = 2 +end + +def method_with_unless + var1 = 1 + unless condition + puts 'foo' + end + var2 = 2 +end diff --git a/t/rubyblock_test.vim b/t/rubyblock_test.vim index dd55ffa..8b2ab0c 100644 --- a/t/rubyblock_test.vim +++ b/t/rubyblock_test.vim @@ -86,6 +86,23 @@ describe '(textobj-rubyblock-a)' end +describe 'nested while and unless blocks' + + before + silent tabnew t/examples.rb + end + + after + silent tabclose + end + + it 'ignores nested while and unless blocks' + Expect SelectAroundFrom(69, '^') ==# [69, 68, 75] + Expect SelectAroundFrom(78, '^') ==# [78, 77, 83] + end + +end + describe '(textobj-rubyblock-i)' before