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

Address Flake8's E127 with "if (" (#102)
authorDaniel Hahler <github@thequod.de>
Sun, 22 Jul 2018 21:54:26 +0000 (23:54 +0200)
committerGitHub <noreply@github.com>
Sun, 22 Jul 2018 21:54:26 +0000 (23:54 +0200)
> continuation line over-indented for visual indent

It appears that the "if (" is just the 4 columns wide that triggers the
extra indent with sw=4.

Might also change/adjust b:control_statement to ignore `if (`, but this
appears to be more flexible/correct.

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

index a095ca64ed2e905043a5bf4d777a31512bede49d..b863370303060ce4c5927435b721439332bb6886 100644 (file)
@@ -225,10 +225,13 @@ function! s:indent_like_opening_paren(lnum)
     " indent further to distinguish the continuation line
     " from the next logical line.
     if text =~# b:control_statement && res == base + s:sw()
-        return base + s:sw() * 2
-    else
-        return res
+        " But only if not inside parens itself (Flake's E127).
+        let [paren_lnum, _] = s:find_opening_paren(paren_lnum)
+        if paren_lnum <= 0
+            return res + s:sw()
+        endif
     endif
+    return res
 endfunction
 
 " Match indent of first block of this type.
index d369c3ed3c3db776879006d40331a3cc2dfe85db..a85edcc97fea6605c56060b72d35d5e2870e6e3d 100644 (file)
@@ -251,6 +251,11 @@ shared_examples_for "vim" do
       indent.should == 0
     end
 
+    it "handles nested expressions (Flake8's E127)" do
+      vim.feedkeys 'i[\<CR>x for x in foo\<CR>if (\<CR>'
+      indent.should == shiftwidth * 2
+    end
+
     it "still handles multiple parens correctly" do
       vim.feedkeys 'iif (111 and (222 and 333\<CR>'
       indent.should == 13