Permalink
Browse files

Indent blocks, started on continued lines

Note that this slightly changes behaviour for other nested stuff.
  • Loading branch information...
1 parent 852596f commit f265e6b09f943d79582244e487a4fa80a9584aa1 @AndrewRadev AndrewRadev committed Nov 21, 2011
Showing with 17 additions and 11 deletions.
  1. +6 −0 etc/examples/indent/continuation_blocks.rb
  2. +9 −9 etc/examples/indent/nested_hashes.rb
  3. +2 −2 indent/ruby.vim
@@ -0,0 +1,6 @@
+def foo
+ opts.on('--coordinator host=HOST[,port=PORT]',
+ 'Specify the HOST and the PORT of the coordinator') do |str|
+ h = sub_opts_to_hash(str)
+ end
+end
@@ -26,26 +26,26 @@ class Foo
# nested { ... } blocks with a continued first line
var.
func1(:param => 'value') {
- var.func2(:param => 'value') {
- puts "test"
- }
+ var.func2(:param => 'value') {
+ puts "test"
+ }
}
# nested hashes with a continued first line
foo,
bar = {
- :bar => {
- :foo { 'bar' => 'baz' },
- :one => 'two',
- :three => 'four'
- }
+ :bar => {
+ :foo { 'bar' => 'baz' },
+ :one => 'two',
+ :three => 'four'
+ }
}
# TODO nested { ... } blocks with a continued first line and a function call
# inbetween
var.
func1(:param => 'value') {
- func1_5(:param => 'value')
+ func1_5(:param => 'value')
var.func2(:param => 'value') {
puts "test"
}
View
@@ -278,7 +278,7 @@ function GetRubyIndent(...)
\ strpart(line, col('.') - 1, 2) !~ 'do'
let ind = virtcol('.') - 1
else
- let ind = indent('.')
+ let ind = indent(s:GetMSL(line('.')))
endif
endif
return ind
@@ -311,7 +311,7 @@ function GetRubyIndent(...)
" If the previous line ended with a block opening, add a level of indent.
if s:Match(lnum, s:block_regex)
- return indent(lnum) + &sw
+ return indent(s:GetMSL(lnum)) + &sw
endif
" If the previous line contained an opening bracket, and we are still in it,

0 comments on commit f265e6b

Please sign in to comment.