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

Improve/fix indent with closing parenthesis (#129)
authorDaniel Hahler <git@thequod.de>
Mon, 13 May 2019 20:48:12 +0000 (22:48 +0200)
committerGitHub <noreply@github.com>
Mon, 13 May 2019 20:48:12 +0000 (22:48 +0200)
Fixes https://github.com/Vimjas/vim-python-pep8-indent/issues/126

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

index 3c86195606f68dfed29429151c8af5ceed6de8dc..aca216e79d69e63da8411a269c9522ae03c6b627 100644 (file)
@@ -222,7 +222,12 @@ function! s:indent_like_opening_paren(lnum)
         if starts_with_closing_paren && !hang_closing
             let res = base
         else
         if starts_with_closing_paren && !hang_closing
             let res = base
         else
-            return base + s:sw()
+            let res = base + s:sw()
+
+            " Special case for parenthesis.
+            if text[paren_col-1] ==# '(' && getline(a:lnum) !~# '\v\)\s*:?\s*$'
+                return res
+            endif
         endif
     else
         " Indent to match position of opening paren.
         endif
     else
         " Indent to match position of opening paren.
index 2ff0cafc72a418a8006f3ad56447fe7b15ab839c..55e2fba42debd58c112b670391dcf43cba755f5c 100644 (file)
@@ -203,9 +203,24 @@ shared_examples_for "vim" do
   end
 
   describe "when using a function definition" do
   end
 
   describe "when using a function definition" do
-      it "indents shiftwidth spaces" do
+      it "handles indent with closing parenthesis on same line" do
           vim.feedkeys 'idef long_function_name(\<CR>arg'
           indent.should == shiftwidth
           vim.feedkeys 'idef long_function_name(\<CR>arg'
           indent.should == shiftwidth
+          vim.feedkeys '):'
+          indent.should == shiftwidth * 2
+      end
+
+      it "handles indent with closing parenthesis on new line" do
+          vim.feedkeys 'idef long_function_name(\<CR>arg'
+          indent.should == shiftwidth
+          vim.feedkeys '\<CR>'
+          indent.should == shiftwidth
+          vim.feedkeys ')'
+          indent.should == (hang_closing ? shiftwidth * 2 : 0)
+          vim.feedkeys ':'
+          indent.should == (hang_closing ? shiftwidth * 2 : 0)
+          vim.feedkeys '\<Esc>k'
+          indent.should == shiftwidth
       end
   end
 
       end
   end