X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/fa0f4802afec544c313f4590825dd48400539440..445ce093b0aaaf767b18c052edbe688e82d18480:/indent/python.vim diff --git a/indent/python.vim b/indent/python.vim index d86eabb..177b8ad 100644 --- a/indent/python.vim +++ b/indent/python.vim @@ -179,6 +179,7 @@ function! s:indent_like_previous_line(lnum) let text = getline(lnum) let start = s:find_start_of_multiline_statement(lnum) let base = indent(start) + let current = indent(lnum + 1) " Jump to last character in previous line. call cursor(lnum, len(text)) @@ -215,6 +216,13 @@ 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 - indent(a:lnum - 1) + if dedent_size < 0 && current % s:sw() == 0 + return -1 + endif + " In all other cases, line up with the start of the previous statement. return base endfunction