From: Daniel Hahler Date: Fri, 16 Nov 2018 14:52:26 +0000 (+0100) Subject: Cover/fix non-matching multiline closing X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/80f44e73fdb2b71d7ef4825b609a682508b2145c?ds=sidebyside;hp=-c Cover/fix non-matching multiline closing --- 80f44e73fdb2b71d7ef4825b609a682508b2145c diff --git a/indent/python.vim b/indent/python.vim index cc9d6c2..b5ea8a9 100644 --- a/indent/python.vim +++ b/indent/python.vim @@ -381,11 +381,12 @@ function! GetPythonPEPIndent(lnum) if match_quotes != -1 " closing multiline string let quotes = line[match_quotes:(match_quotes+2)] - let pairpos = searchpairpos(quotes, '', quotes, 'b', 1, g:python_pep8_indent_searchpair_timeout) + call cursor(a:lnum, 1) + let pairpos = searchpairpos(quotes, '', quotes, 'bW', '', 0, g:python_pep8_indent_searchpair_timeout) if pairpos[0] != 0 return indent(pairpos[0]) else - " TODO: test to cover this! + return -1 endif endif diff --git a/spec/indent/indent_spec.rb b/spec/indent/indent_spec.rb index 400ec11..68b545f 100644 --- a/spec/indent/indent_spec.rb +++ b/spec/indent/indent_spec.rb @@ -502,11 +502,26 @@ shared_examples_for "multiline strings" do end describe "when after a docstring" do - before { vim.feedkeys 'i """' } it "it does indent the next line to the docstring" do - vim.feedkeys '\' + vim.feedkeys 'i """\' + indent.should == 4 + proposed_indent.should == 4 + end + + it "indents the closing docstring quotes" do + vim.feedkeys 'i """\\"""' indent.should == 4 proposed_indent.should == 4 + vim.echo('getline(3)').should == ' """' + end + + it "indents non-matching docstring quotes" do + vim.feedkeys 'i """\\' + vim.feedkeys "0C'''" + vim.echo('line(".")').should == "4" + vim.echo('getline(".")').should == "'''" + indent.should == 0 + proposed_indent.should == -1 end end