Permalink
Browse files

Fixes to closing bracket handler

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...
1 parent ebc94f6 commit f27d520ca79bf41e54cad0893839acfa8a98b9d2 @AndrewRadev AndrewRadev committed Oct 14, 2012
Showing with 6 additions and 6 deletions.
  1. +4 −4 etc/examples/indent/closing_brackets.rb
  2. +2 −2 indent/ruby.vim
@@ -1,16 +1,16 @@
[1, [2,
[3],
3],
-4]
+ 4]
[1, [2,
3],
-4]
+ 4]
[1, {2 =>
3},
-4]
+ 4]
[1, f(2,
3),
-4]
+ 4]
View
@@ -413,7 +413,7 @@ function GetRubyIndent(...)
"
" If it contained hanging closing brackets, find the rightmost one, find its
" match and indent according to that.
- if line =~ '[][(){}]'
+ if line =~ '[[({]' || line =~ '[])}]\s*\%(#.*\)\=$'
let [opening, closing] = s:ExtraBrackets(lnum)
if opening.pos != -1
@@ -428,7 +428,7 @@ function GetRubyIndent(...)
return nonspace > 0 ? nonspace : ind + &sw
endif
elseif closing.pos != -1
- call cursor(lnum, closing.pos)
+ call cursor(lnum, closing.pos + 1)
normal! %
return indent('.')
else

0 comments on commit f27d520

Please sign in to comment.