X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/fa0f4802afec544c313f4590825dd48400539440..b430740f94385419258e16fdf5f22dd20a5637e6:/indent/python.vim diff --git a/indent/python.vim b/indent/python.vim index d86eabb..461e962 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(a:lnum) " 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 - base + 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