Skip to content

Commit

Permalink
Different indent behavior for a line ending in an open parenthesis.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpope committed Nov 9, 2006
1 parent 3666686 commit 91937dd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2006-11-09 Tim Pope <vim@tpope.info>

* indent.ruby.vim: Only increase one 'shiftwidth' after a line ending
with an open parenthesis.

2006-11-08 Tim Pope <vim@tpope.info>

* indent/eruby.vim: Rearranged keywords; new 'indentkeys'
Expand Down
14 changes: 12 additions & 2 deletions indent/ruby.vim
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ function GetRubyIndent()
call cursor(v:lnum, col)
let bs = strpart('(){}[]', stridx(')}]', line[col - 1]) * 2, 2)
if searchpair(escape(bs[0], '\['), '', bs[1], 'bW', s:skip_expr) > 0
let ind = line[col-1]==')' ? virtcol('.')-1 : indent(s:GetMSL(line('.')))
if line[col-1]==')' && col('.') != col('$') - 1
let ind = virtcol('.')-1
else
let ind = indent(s:GetMSL(line('.')))
endif
endif
return ind
endif
Expand Down Expand Up @@ -274,7 +278,11 @@ function GetRubyIndent()
if line =~ '[[({]'
let counts = s:LineHasOpeningBrackets(lnum)
if counts[0] == '1' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0
return virtcol('.')
if col('.') + 1 == col('$')
return ind + &sw
else
return virtcol('.')
endif
elseif counts[1] == '1' || counts[2] == '1'
return ind + &sw
else
Expand Down Expand Up @@ -361,3 +369,5 @@ endfunction

let &cpo = s:cpo_save
unlet s:cpo_save

" vim:set sw=2 sts=2 ts=8 noet ff=unix:

0 comments on commit 91937dd

Please sign in to comment.