From: Daniel Hahler Date: Sat, 17 Nov 2018 18:10:46 +0000 (+0100) Subject: Keep/handle (auto)indent with O (#119) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/8d64e05e37bc3c9a01bd7c5d6e2948470551c351?hp=-c Keep/handle (auto)indent with O (#119) --- 8d64e05e37bc3c9a01bd7c5d6e2948470551c351 diff --git a/indent/python.vim b/indent/python.vim index 55b2b1b..6f84637 100644 --- a/indent/python.vim +++ b/indent/python.vim @@ -313,7 +313,7 @@ function! s:indent_like_previous_line(lnum) return -1 endif - if !empty && s:is_dedented_already(current, base) + if (current || !empty) && s:is_dedented_already(current, base) return -1 endif diff --git a/spec/indent/indent_spec.rb b/spec/indent/indent_spec.rb index 400ec11..aa796df 100644 --- a/spec/indent/indent_spec.rb +++ b/spec/indent/indent_spec.rb @@ -685,3 +685,22 @@ describe "Compact multiline dict" do proposed_indent.should == 0 end end + +describe "Using O" do + before { vim.feedkeys 'iif foo:\' } + + it "respects autoindent" do + vim.feedkeys '1\\' + indent.should == shiftwidth + vim.feedkeys '\ko' + indent.should == shiftwidth + vim.feedkeys '\kO' + indent.should == shiftwidth + # Uses/keeps indent from line above + vim.feedkeys '\i2\O' + indent.should == shiftwidth + # Uses/keeps indent from line above + vim.feedkeys '\j\O' + indent.should == 0 + end +end