Skip to content

Commit c7e6baa

Browse files
committed
fixed folding issue when definition was on first line (gh issue 808)
1 parent 76c582b commit c7e6baa

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
@@ -1,4 +1,4 @@
1-
" Python-mode folding functions
1+
k" Python-mode folding function2
22
" Notice that folding is based on single line so complex regular expressions
33
" that take previous line into consideration are not fit for the job.
44

@@ -156,10 +156,14 @@ fun! s:BlockStart(line_number) "{{{
156156
" In case the end of the block is indented to a higher level than the def
157157
" statement plus one shiftwidth, we need to find the indent level at the
158158
" bottom of that if/for/try/while/etc. block.
159-
let previous_definition = searchpos(s:def_regex, 'bcnW')
159+
" Flags from searchpos() (same as search()):
160+
" b: search Backward instead of forward
161+
" n: do Not move the cursor
162+
" W: don't Wrap around the end of the file
163+
let previous_definition = searchpos(s:def_regex, 'bnW')
160164
if previous_definition != [0, 0]
161165
while previous_definition != [0, 0] && indent(previous_definition[0]) >= indent(a:line_number)
162-
let previous_definition = searchpos(s:def_regex, 'bncW')
166+
let previous_definition = searchpos(s:def_regex, 'bnW')
163167
call cursor(previous_definition[0] - 1, 0)
164168
endwhile
165169
endif

0 commit comments

Comments
 (0)