From 0d5b5cf86bb19c03a0f569cb4eae49a7fd661888 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 3 Jul 2016 13:09:49 +0200 Subject: [PATCH 1/1] 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. --- indent/python.vim | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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) -- 2.39.5