Skip to content

Commit f27d520

Browse files
committed
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.
1 parent ebc94f6 commit f27d520

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[1, [2,
22
[3],
33
3],
4-
4]
4+
4]
55

66
[1, [2,
77
3],
8-
4]
8+
4]
99

1010
[1, {2 =>
1111
3},
12-
4]
12+
4]
1313

1414
[1, f(2,
1515
3),
16-
4]
16+
4]

indent/ruby.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ function GetRubyIndent(...)
413413
"
414414
" If it contained hanging closing brackets, find the rightmost one, find its
415415
" match and indent according to that.
416-
if line =~ '[][(){}]'
416+
if line =~ '[[({]' || line =~ '[])}]\s*\%(#.*\)\=$'
417417
let [opening, closing] = s:ExtraBrackets(lnum)
418418

419419
if opening.pos != -1
@@ -428,7 +428,7 @@ function GetRubyIndent(...)
428428
return nonspace > 0 ? nonspace : ind + &sw
429429
endif
430430
elseif closing.pos != -1
431-
call cursor(lnum, closing.pos)
431+
call cursor(lnum, closing.pos + 1)
432432
normal! %
433433
return indent('.')
434434
else

0 commit comments

Comments
 (0)