Skip to content

Commit f265e6b

Browse files
committed
Indent blocks, started on continued lines
Note that this slightly changes behaviour for other nested stuff.
1 parent 852596f commit f265e6b

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def foo
2+
opts.on('--coordinator host=HOST[,port=PORT]',
3+
'Specify the HOST and the PORT of the coordinator') do |str|
4+
h = sub_opts_to_hash(str)
5+
end
6+
end

etc/examples/indent/nested_hashes.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,26 @@ class Foo
2626
# nested { ... } blocks with a continued first line
2727
var.
2828
func1(:param => 'value') {
29-
var.func2(:param => 'value') {
30-
puts "test"
31-
}
29+
var.func2(:param => 'value') {
30+
puts "test"
31+
}
3232
}
3333

3434
# nested hashes with a continued first line
3535
foo,
3636
bar = {
37-
:bar => {
38-
:foo { 'bar' => 'baz' },
39-
:one => 'two',
40-
:three => 'four'
41-
}
37+
:bar => {
38+
:foo { 'bar' => 'baz' },
39+
:one => 'two',
40+
:three => 'four'
41+
}
4242
}
4343

4444
# TODO nested { ... } blocks with a continued first line and a function call
4545
# inbetween
4646
var.
4747
func1(:param => 'value') {
48-
func1_5(:param => 'value')
48+
func1_5(:param => 'value')
4949
var.func2(:param => 'value') {
5050
puts "test"
5151
}

indent/ruby.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ function GetRubyIndent(...)
278278
\ strpart(line, col('.') - 1, 2) !~ 'do'
279279
let ind = virtcol('.') - 1
280280
else
281-
let ind = indent('.')
281+
let ind = indent(s:GetMSL(line('.')))
282282
endif
283283
endif
284284
return ind
@@ -311,7 +311,7 @@ function GetRubyIndent(...)
311311

312312
" If the previous line ended with a block opening, add a level of indent.
313313
if s:Match(lnum, s:block_regex)
314-
return indent(lnum) + &sw
314+
return indent(s:GetMSL(lnum)) + &sw
315315
endif
316316

317317
" If the previous line contained an opening bracket, and we are still in it,

0 commit comments

Comments
 (0)