From 0c4a52f1f101f61376900fa655ffa256437bedc8 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 26 Jul 2018 09:35:30 +0200 Subject: [PATCH] Fix indenting of "else" with outer if Fixes https://github.com/Vimjas/vim-python-pep8-indent/issues/97. --- indent/python.vim | 2 -- spec/indent/indent_spec.rb | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/indent/python.vim b/indent/python.vim index 8444a22..f13ae9e 100644 --- a/indent/python.vim +++ b/indent/python.vim @@ -154,8 +154,6 @@ function! s:find_start_of_block(lnum, types, multiple) if index(r, indent) == -1 let r += [indent] endif - " Remove any handled type, e.g. 'if'. - call remove(types, index(types, type)) endif endfor let last_indent = indent(lnum) diff --git a/spec/indent/indent_spec.rb b/spec/indent/indent_spec.rb index e60da62..400ec11 100644 --- a/spec/indent/indent_spec.rb +++ b/spec/indent/indent_spec.rb @@ -401,10 +401,22 @@ shared_examples_for "vim" do end describe "when an else is used inside of a nested if" do - before { vim.feedkeys 'iif foo:\\if bar:\\\pass\' } - it "indents an else to the inner if" do + before { vim.feedkeys 'iif foo:\if bar:\pass\' } + it "indents the else to the inner if" do vim.feedkeys 'else:' - indent.should == shiftwidth * 2 + indent.should == shiftwidth + end + end + + describe "when an else is used outside of a nested if" do + before { vim.feedkeys 'iif True:\if True:\pass\\0' } + it "indents the else to the outer if" do + indent.should == 0 + proposed_indent.should == shiftwidth + + vim.feedkeys 'ielse:' + indent.should == 0 + proposed_indent.should == 0 end end -- 2.39.5