Skip to content

Commit f4f95ee

Browse files
committed
Fix regression with colon-at-eol detection (#44)
Instead of using `search` it now goes back and breaks if a char is found that should not get skipped. Fixes #44 Closes #45
1 parent 955f7c0 commit f4f95ee

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

indent/python.vim

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,17 +243,16 @@ function! s:indent_like_previous_line(lnum)
243243
let ignore_last_char = eval(s:skip_special_chars)
244244

245245
" Search for final colon that is not inside something to be ignored.
246-
while search(':', 'bcW', lnum)
246+
while 1
247247
let curpos = getpos(".")[2]
248248
if curpos == 1 | break | endif
249-
if eval(s:skip_special_chars)
249+
if eval(s:skip_special_chars) || text[curpos-1] =~ '\s'
250250
normal! h
251251
continue
252-
endif
253-
if !s:match_expr_on_line(s:skip_special_chars, lnum, curpos)
252+
elseif text[curpos-1] == ':'
254253
return base + s:sw()
255254
endif
256-
normal! h
255+
break
257256
endwhile
258257

259258
if text =~ '\\$' && !ignore_last_char

spec/indent/indent_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@
153153
end
154154
end
155155

156+
describe "when the previous line has a list slice" do
157+
it "does not indent" do
158+
vim.feedkeys 'ib = a[2:]\<CR>'
159+
indent.should == 0
160+
proposed_indent.should == 0
161+
end
162+
end
163+
156164
describe "when after an '(' that is followed by an unfinished string" do
157165
before { vim.feedkeys 'itest("""' }
158166

0 commit comments

Comments
 (0)