Skip to content

Commit 80f44e7

Browse files
committed
Cover/fix non-matching multiline closing
1 parent 6ef7bc1 commit 80f44e7

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

indent/python.vim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,12 @@ function! GetPythonPEPIndent(lnum)
381381
if match_quotes != -1
382382
" closing multiline string
383383
let quotes = line[match_quotes:(match_quotes+2)]
384-
let pairpos = searchpairpos(quotes, '', quotes, 'b', 1, g:python_pep8_indent_searchpair_timeout)
384+
call cursor(a:lnum, 1)
385+
let pairpos = searchpairpos(quotes, '', quotes, 'bW', '', 0, g:python_pep8_indent_searchpair_timeout)
385386
if pairpos[0] != 0
386387
return indent(pairpos[0])
387388
else
388-
" TODO: test to cover this!
389+
return -1
389390
endif
390391
endif
391392

spec/indent/indent_spec.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,11 +502,26 @@
502502
end
503503

504504
describe "when after a docstring" do
505-
before { vim.feedkeys 'i """' }
506505
it "it does indent the next line to the docstring" do
507-
vim.feedkeys '\<CR>'
506+
vim.feedkeys 'i """\<CR>'
507+
indent.should == 4
508+
proposed_indent.should == 4
509+
end
510+
511+
it "indents the closing docstring quotes" do
512+
vim.feedkeys 'i """\<CR>\<CR>"""'
508513
indent.should == 4
509514
proposed_indent.should == 4
515+
vim.echo('getline(3)').should == ' """'
516+
end
517+
518+
it "indents non-matching docstring quotes" do
519+
vim.feedkeys 'i """\<CR>\<Esc>'
520+
vim.feedkeys "0C'''"
521+
vim.echo('line(".")').should == "4"
522+
vim.echo('getline(".")').should == "'''"
523+
indent.should == 0
524+
proposed_indent.should == -1
510525
end
511526
end
512527

0 commit comments

Comments
 (0)