From: Daniel Hahler Date: Sun, 3 Jul 2016 11:09:49 +0000 (+0200) Subject: Factor out is_dedented_already X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/0d5b5cf86bb19c03a0f569cb4eae49a7fd661888?hp=-c Factor out is_dedented_already Not really necessary, but I did it when using it somewhere else initially, and it might be more readable after all. --- 0d5b5cf86bb19c03a0f569cb4eae49a7fd661888 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)