From: Daniel Hahler Date: Thu, 16 Nov 2017 16:28:46 +0000 (+0100) Subject: use 50 for round parens, add tests X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/5e955165c22ec1bb874728195a7ce2a48b2edbac?ds=sidebyside use 50 for round parens, add tests --- diff --git a/indent/python.vim b/indent/python.vim index 22ca76f..e251ce2 100644 --- a/indent/python.vim +++ b/indent/python.vim @@ -44,7 +44,7 @@ let s:block_rules_multiple = { \ } " Pairs to look for when searching for opening parenthesis. " The value is the maximum offset in lines. -let s:paren_pairs = {'()': 10, '[]': 100, '{}': 1000} +let s:paren_pairs = {'()': 50, '[]': 100, '{}': 1000} " Maximum offset when looking for multiline statements (in round parenthesis). let s:maxoff_multiline_statement = 50 diff --git a/spec/indent/indent_spec.rb b/spec/indent/indent_spec.rb index 23c1629..b08203b 100644 --- a/spec/indent/indent_spec.rb +++ b/spec/indent/indent_spec.rb @@ -587,3 +587,67 @@ describe "vim for cython" do end end end + +describe "Handles far away opening parens" do + before { vim.feedkeys '\ggdGifrom foo import (' } + + it "indents by one level" do + vim.feedkeys '\' + proposed_indent.should == shiftwidth + end + + it "indents by one level for 10 lines" do + vim.command('set paste | exe "norm 9o" | set nopaste') + vim.feedkeys '\o' + indent.should == shiftwidth + end + + it "indents by one level for 50 lines" do + vim.command('set paste | exe "norm 49o" | set nopaste') + vim.feedkeys '\o' + indent.should == shiftwidth + end +end + +describe "Handles far away opening square brackets" do + before { vim.feedkeys '\ggdGibar = [' } + + it "indents by one level" do + vim.feedkeys '\' + proposed_indent.should == shiftwidth + end + + it "indents by one level for 10 lines" do + vim.command('set paste | exe "norm 9o" | set nopaste') + vim.feedkeys '\o' + indent.should == shiftwidth + end + + it "indents by one level for 100 lines" do + vim.command('set paste | exe "norm 99o" | set nopaste') + vim.feedkeys '\o' + indent.should == shiftwidth + end +end + +describe "Handles far away opening curly brackets" do + before { vim.feedkeys '\ggdGijson = {' } + + it "indents by one level" do + vim.feedkeys '\' + vim.feedkeys '\o' + proposed_indent.should == shiftwidth + end + + it "indents by one level for 10 lines" do + vim.command('set paste | exe "norm 9o" | set nopaste') + vim.feedkeys '\o' + indent.should == shiftwidth + end + + it "indents by one level for 1000 lines" do + vim.command('set paste | exe "norm 999o" | set nopaste') + vim.feedkeys '\o' + indent.should == shiftwidth + end +end