Skip to content

Commit 08e4085

Browse files
authored
Merge pull request #53 from blueyed/factor-out-dedented-already
Factor out is_dedented_already
2 parents 2dcdd21 + 0d5b5cf commit 08e4085

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

indent/python.vim

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,21 @@ function! s:indent_like_previous_line(lnum)
281281
return -1
282282
endif
283283

284-
" If this line is dedented and the number of indent spaces is valid
285-
" (multiple of the indentation size), trust the user
286-
let dedent_size = current - base
287-
if dedent_size < 0 && current % s:sw() == 0
284+
if s:is_dedented_already(current, base)
288285
return -1
289286
endif
290287

291288
" In all other cases, line up with the start of the previous statement.
292289
return base
293290
endfunction
294291

292+
" If this line is dedented and the number of indent spaces is valid
293+
" (multiple of the indentation size), trust the user.
294+
function! s:is_dedented_already(current, base)
295+
let dedent_size = a:current - a:base
296+
return (dedent_size < 0 && a:current % s:sw() == 0) ? 1 : 0
297+
endfunction
298+
295299
" Is the syntax at lnum (and optionally cnum) a python string?
296300
function! s:is_python_string(lnum, ...)
297301
let line = getline(a:lnum)

0 commit comments

Comments
 (0)