From: Hynek Schlawack Date: Sun, 3 Jul 2016 11:17:31 +0000 (+0200) Subject: Merge pull request #53 from blueyed/factor-out-dedented-already X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/08e40851cc56693aa65f3e6c7e641f2f03a366bd?hp=2dcdd210d617e6941ec2d025a80ea16652441a2f Merge pull request #53 from blueyed/factor-out-dedented-already Factor out is_dedented_already --- 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)