]> git.madduck.net Git - etc/vim.git/blobdiff - indent/python.vim

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:

Fix outer "elif" with inner "if" (#136)
[etc/vim.git] / indent / python.vim
index 3c86195606f68dfed29429151c8af5ceed6de8dc..047ae3d7bad1ec3157ceffabcc1479598ae7a783 100644 (file)
@@ -158,8 +158,8 @@ function! s:find_start_of_block(lnum, types, skip, multiple) abort
     else
       let re_skip = ''
     endif
-    let lnum = a:lnum
-    let last_indent = indent(lnum) + 1
+    let last_indent = indent(a:lnum) + 1
+    let lnum = a:lnum - 1
     while lnum > 0 && last_indent > 0
         let indent = indent(lnum)
         if indent < last_indent
@@ -222,7 +222,12 @@ function! s:indent_like_opening_paren(lnum)
         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.
@@ -255,7 +260,7 @@ function! s:indent_like_block(lnum)
             endif
 
             let [blocks, skip] = blocks_ignore
-            let indents = s:find_start_of_block(a:lnum - 1, blocks, skip, multiple)
+            let indents = s:find_start_of_block(a:lnum, blocks, skip, multiple)
             if empty(indents)
                 return -1
             endif