Skip to content

Commit 8aeb039

Browse files
committed
Fixed corner case of folding crash when there is a definition on the first line (gh issue python-mode#839)
1 parent 0b3bbad commit 8aeb039

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

autoload/pymode/folding.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ fun! pymode#folding#foldcase(lnum) "{{{
207207
endfunction "}}}
208208

209209
fun! s:BlockStart(lnum) "{{{
210-
" Returns the definition statement which encloses the current line.
210+
" Returns the definition statement line which encloses the current line.
211211

212212
let line = getline(a:lnum)
213213
if line !~ s:blank_regex
@@ -227,7 +227,11 @@ fun! s:BlockStart(lnum) "{{{
227227
" n: do Not move the cursor
228228
" W: don't Wrap around the end of the file
229229
let previous_definition = searchpos(s:def_regex, 'bnW')
230-
if previous_definition != [0, 0]
230+
231+
" Corner case of function being defined on the first line.
232+
if previous_definition[0] == 1
233+
" Just skip the while loop.
234+
elseif previous_definition != [0, 0]
231235
" Lines that are blank have zero indent.
232236
while previous_definition != [0, 0]
233237
\ && indent(previous_definition[0]) >= l:inferred_indent

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy