Skip to content

Commit 88333bd

Browse files
committed
s:find_opening_paren: remove wrong optimization
1 parent 61e1c4d commit 88333bd

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

indent/python.vim

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,11 @@ function! s:find_opening_paren(lnum, col)
119119

120120
let nearest = [0, 0]
121121
let timeout = g:python_pep8_indent_searchpair_timeout
122+
let skip_special_chars = 's:_skip_special_chars(line("."), col("."))'
122123
for [p, maxoff] in items(s:paren_pairs)
123124
let stopline = max([0, line('.') - maxoff, nearest[0]])
124-
let found = 0
125-
while 1
126-
let next = searchpairpos('\V'.p[0], '', '\V'.p[1], 'bnW', '', stopline, timeout)
127-
if !next[0] || !s:_skip_special_chars(next[0], next[1])
128-
break
129-
endif
130-
call cursor(next[0], next[1])
131-
endwhile
125+
let next = searchpairpos(
126+
\ '\V'.p[0], '', '\V'.p[1], 'bnW', skip_special_chars, stopline, timeout)
132127
if next[0] && (next[0] > nearest[0] || (next[0] == nearest[0] && next[1] > nearest[1]))
133128
let nearest = next
134129
endif

spec/indent/indent_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,3 +719,11 @@
719719
indent.should == 0
720720
end
721721
end
722+
723+
describe "searchpairpos" do
724+
before { vim.feedkeys '\<ESC>ggdG' }
725+
it "handles nested parenthesis" do
726+
vim.feedkeys 'iif foo.startswith("("):\<CR>'
727+
indent.should == shiftwidth
728+
end
729+
end

0 commit comments

Comments
 (0)