X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/2dcdd210d617e6941ec2d025a80ea16652441a2f..08e40851cc56693aa65f3e6c7e641f2f03a366bd:/indent/python.vim diff --git a/indent/python.vim b/indent/python.vim index 4306985..5c701e4 100644 --- a/indent/python.vim +++ b/indent/python.vim @@ -281,10 +281,7 @@ function! s:indent_like_previous_line(lnum) return -1 endif - " If this line is dedented and the number of indent spaces is valid - " (multiple of the indentation size), trust the user - let dedent_size = current - base - if dedent_size < 0 && current % s:sw() == 0 + if s:is_dedented_already(current, base) return -1 endif @@ -292,6 +289,13 @@ function! s:indent_like_previous_line(lnum) return base endfunction +" If this line is dedented and the number of indent spaces is valid +" (multiple of the indentation size), trust the user. +function! s:is_dedented_already(current, base) + let dedent_size = a:current - a:base + return (dedent_size < 0 && a:current % s:sw() == 0) ? 1 : 0 +endfunction + " Is the syntax at lnum (and optionally cnum) a python string? function! s:is_python_string(lnum, ...) let line = getline(a:lnum)