8000 Fix edge case bug at end of top-level fold · python-mode/python-mode@391ece0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 391ece0

Browse files
committed
Fix edge case bug at end of top-level fold
1 parent 906eff5 commit 391ece0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

autoload/pymode/folding.vim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,18 @@ fun! pymode#folding#expr(lnum) "{{{
7979
" own fold. If the class/def containing the current line is on
8080
" the first line it can't be nested, and if the this block
8181
" ends on the last line, it contains no trailing code that
82-
" should not be folded. Otherwise, we know the current line
83-
" is at the end of a nested def.
82+
" should not be folded. Finally, if the next non-blank line
83+
" after the end of the previous def is less indented than the
84+
" previous def, it is not part of the same fold as that def.
85+
" Otherwise, we know the current line is at the end of a
86+
" nested def.
8487
if next_def_indent < last_block_indent && last_block > 1 && last_block_end < line('$')
88+
\ && indent(nextnonblank(last_block_end)) >= last_block_indent
8589

8690
" Include up to one blank line in the fold
8791
let fold_end = min([prevnonblank(last_block_end - 1) + 1, last_block_end])
8892
if a:lnum == fold_end
89-
return 's1'
93+
return next_def ? 's1' : 0
9094
else
9195
return '='
9296
endif

0 commit comments

Comments
 (0)
0