]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

use 50 for round parens, add tests
authorDaniel Hahler <git@thequod.de>
Thu, 16 Nov 2017 16:28:46 +0000 (17:28 +0100)
committerDaniel Hahler <git@thequod.de>
Thu, 16 Nov 2017 17:41:54 +0000 (18:41 +0100)
indent/python.vim
spec/indent/indent_spec.rb

index 22ca76fcb9e3791ea721aeee99cebe1c614a37b7..e251ce286b944d36f792b22e14c661db01c50493 100644 (file)
@@ -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
index 23c16293e953532190ff1273a01029a5b6ed5f7c..b08203b8a0b05d89e71c0fdfab9a26b67a82b8dc 100644 (file)
@@ -587,3 +587,67 @@ describe "vim for cython" do
       end
   end
 end
+
+describe "Handles far away opening parens" do
+  before { vim.feedkeys '\<ESC>ggdGifrom foo import (' }
+
+  it "indents by one level" do
+    vim.feedkeys '\<CR>'
+    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 '\<Esc>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 '\<Esc>o'
+    indent.should == shiftwidth
+  end
+end
+
+describe "Handles far away opening square brackets" do
+  before { vim.feedkeys '\<ESC>ggdGibar = [' }
+
+  it "indents by one level" do
+    vim.feedkeys '\<CR>'
+    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 '\<Esc>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 '\<Esc>o'
+    indent.should == shiftwidth
+  end
+end
+
+describe "Handles far away opening curly brackets" do
+  before { vim.feedkeys '\<ESC>ggdGijson = {' }
+
+  it "indents by one level" do
+    vim.feedkeys '\<CR>'
+    vim.feedkeys '\<Esc>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 '\<Esc>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 '\<Esc>o'
+    indent.should == shiftwidth
+  end
+end