Skip to content

Commit

Permalink
Fixes to closing bracket handler
Browse files Browse the repository at this point in the history
Only match closing brackets that are at the end of a line, and get the
right bracket position.

This still doesn't handle the actual line where the brackets are closed,
just the following one.
  • Loading branch information
AndrewRadev committed Oct 14, 2012
1 parent ebc94f6 commit f27d520
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions etc/examples/indent/closing_brackets.rb
@@ -1,16 +1,16 @@
[1, [2, [1, [2,
[3], [3],
3], 3],
4] 4]


[1, [2, [1, [2,
3], 3],
4] 4]


[1, {2 => [1, {2 =>
3}, 3},
4] 4]


[1, f(2, [1, f(2,
3), 3),
4] 4]
4 changes: 2 additions & 2 deletions indent/ruby.vim
Expand Up @@ -413,7 +413,7 @@ function GetRubyIndent(...)
" "
" If it contained hanging closing brackets, find the rightmost one, find its " If it contained hanging closing brackets, find the rightmost one, find its
" match and indent according to that. " match and indent according to that.
if line =~ '[][(){}]' if line =~ '[[({]' || line =~ '[])}]\s*\%(#.*\)\=$'
let [opening, closing] = s:ExtraBrackets(lnum) let [opening, closing] = s:ExtraBrackets(lnum)


if opening.pos != -1 if opening.pos != -1
Expand All @@ -428,7 +428,7 @@ function GetRubyIndent(...)
return nonspace > 0 ? nonspace : ind + &sw return nonspace > 0 ? nonspace : ind + &sw
endif endif
elseif closing.pos != -1 elseif closing.pos != -1
call cursor(lnum, closing.pos) call cursor(lnum, closing.pos + 1)
normal! % normal! %
return indent('.') return indent('.')
else else
Expand Down

0 comments on commit f27d520

Please sign in to comment.