]> 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:

Merge branch 'clayg-fix-10'
authorHynek Schlawack <schlawack@variomedia.de>
Tue, 24 Sep 2013 08:10:43 +0000 (10:10 +0200)
committerHynek Schlawack <schlawack@variomedia.de>
Tue, 24 Sep 2013 08:10:43 +0000 (10:10 +0200)
Fixes #10

AUTHORS.rst
indent/python.vim
spec/indent/indent_spec.rb

index 7333ee47facb294ec1f2d4b1496880f44d6f504f..e12a0c93e2ca4e203304ba582692ac84e7a97bb8 100644 (file)
@@ -6,6 +6,7 @@ Credits
 It is currently maintained by Hynek Schlawack with the generous help of the following contributors:
 
 - 0player
+- Clay Gerrard
 - Johann Klähn
 - Joseph Irwin
 - Steve Losh
index 9c3aa0cda4293d75366cf398f7861d00ffd83cbe..2c305471e766e9acceb98549845cec4c71fc31a8 100644 (file)
@@ -160,15 +160,17 @@ function! GetPythonPEPIndent(lnum)
         return -1
     endif
 
-    " If this line is explicitly joined, try to find an indentation that looks
-    " good.
+    " If this line is explicitly joined, find the first indentation that is a
+    " multiple of four and will distinguish itself from next logical line.
     if pline =~ '\\$'
-        let compound_statement = '^\s*\(if\|while\|for\s.*\sin\|except\)\s*'
-        let maybe_indent = matchend(getline(sslnum), compound_statement)
-        if maybe_indent != -1
-            return maybe_indent
+        let maybe_indent = indent(sslnum) + &sw
+        let control_structure = '^\s*\(if\|while\|for\s.*\sin\|except\)\s*'
+        if match(getline(sslnum), control_structure) != -1
+            " add extra indent to avoid E125
+            return maybe_indent + &sw
         else
-            return indent(sslnum) + &sw * 2
+            " control structure not found
+            return maybe_indent
         endif
     endif
 
index c3488f3c3f23f71d100e55fed0b4edf5454a9a28..40269fc6543ea5c0387ebb9806e7a334b5f652ff 100644 (file)
@@ -67,6 +67,30 @@ describe "vim" do
     end
   end
 
+  describe "when using simple control structures" do
+      it "indents shiftwidth spaces" do
+          vim.feedkeys 'iwhile True:\<CR>pass'
+          indent.should == shiftwidth
+      end
+  end
+
+  describe "when a line breaks with a manual '\\'" do
+    it "indents shiftwidth spaces on normal line" do
+        vim.feedkeys 'ivalue = test + \\\\\<CR>'
+        indent.should == shiftwidth
+    end
+
+    it "indents 2x shiftwidth spaces for control structures" do
+        vim.feedkeys 'iif somevalue == xyz and \\\\\<CR>'
+        indent.should == shiftwidth * 2
+    end
+
+    it "indents relative to line above" do
+        vim.feedkeys 'i\tvalue = test + \\\\\<CR>'
+        indent.should == shiftwidth * 2
+    end
+  end
+
   def shiftwidth
     @shiftwidth ||= vim.echo("exists('*shiftwidth') ? shiftwidth() : &sw").to_i
   end