Skip to content

Commit 5f4184f

Browse files
authored
Revert "Improve s:find_start_of_multiline_statement: only look for round parens" (#95)
This reverts commit 922268f. Add a regression test. Conflicts: indent/python.vim
1 parent 797b82c commit 5f4184f

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

indent/python.vim

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ let s:block_rules_multiple = {
4646
" The value is the maximum offset in lines.
4747
let s:paren_pairs = {'()': 50, '[]': 100, '{}': 1000}
4848

49-
" Maximum offset when looking for multiline statements (in round parenthesis).
50-
let s:maxoff_multiline_statement = 50
51-
5249
if &filetype ==# 'pyrex' || &filetype ==# 'cython'
5350
let b:control_statement = '\v^\s*(class|def|if|while|with|for|except|cdef|cpdef)>'
5451
else
@@ -125,21 +122,19 @@ function! s:find_opening_paren(...)
125122
return nearest
126123
endfunction
127124

128-
" Find the start of a multi-line statement (based on surrounding parens).
125+
" Find the start of a multi-line statement
129126
function! s:find_start_of_multiline_statement(lnum)
130127
let lnum = a:lnum
131128
while lnum > 0
132-
" XXX: not tested?!
133129
if getline(lnum - 1) =~# '\\$'
134130
let lnum = prevnonblank(lnum - 1)
135131
else
136-
call cursor(lnum, 1)
137-
let stopline = max([1, lnum - s:maxoff_multiline_statement])
138-
let pos = searchpairpos('\V(', '', '\V)', 'bnW', s:skip_special_chars, stopline)
139-
if pos[0]
140-
return pos[0]
132+
let [paren_lnum, _] = s:find_opening_paren(lnum)
133+
if paren_lnum < 1
134+
return lnum
135+
else
136+
let lnum = paren_lnum
141137
endif
142-
return lnum
143138
endif
144139
endwhile
145140
endfunction

spec/indent/indent_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,3 +651,18 @@
651651
indent.should == shiftwidth
652652
end
653653
end
654+
655+
describe "Compact multiline dict" do
656+
before { vim.feedkeys '\<ESC>ggdGid = {"one": 1,' }
657+
658+
it "gets indented correctly" do
659+
vim.feedkeys '\<CR>'
660+
proposed_indent.should == 5
661+
662+
vim.feedkeys '"two": 2}'
663+
proposed_indent.should == 5
664+
665+
vim.feedkeys '\<CR>'
666+
proposed_indent.should == 0
667+
end
668+
end

0 commit comments

Comments
 (0)