1- " Fold routines for python code, version 2.4
1+ " Fold routines for python code, version 2.5
22" Source: http://www.vim.org/scripts/script.php?script_id=2527
33" Last Change: 2009 Feb 6
44" Author: Jurjen Bos
@@ -65,20 +65,16 @@ function! GetBlockIndent(lnum)
6565 " Auxiliary function; determines the indent level of the surrounding def/class
6666 " "global" lines are level 0, first def &shiftwidth, and so on
6767 " scan backwards for class/def that is shallower or equal
68- let p = prevnonblank (a: lnum )
69- " skip comments and empty lines, to get proper initial indent
70- while p >0 && getline (p ) = ~ ' ^\s*#\|^$'
71- let p = prevnonblank (p - 1 )
72- endwhile
73- let ind = indent (p )
68+ let ind = 100
69+ let p = a: lnum
7470 while indent (p ) >= 0
7571 let p = p - 1
7672 " skip deeper lines, comments and empty lines
7773 if indent (p ) >= ind || getline (p ) = ~ ' ^$\|^\s*#'
7874 continue
7975 " indent is strictly less at this point: check for def/class
8076 elseif getline (p ) = ~ ' ^\s*\(class\s.*:\|def\s\)'
81- " this is the level!
77+ " level is one more than this def/class
8278 return indent (p ) + &shiftwidth
8379 " zero-level regular line
8480 elseif indent (p ) == 0
@@ -103,7 +99,7 @@ function! GetPythonFold(lnum)
10399 " return -1
104100 " some speed optimizations for common cases: same level if:
105101 " - indent positive and non-decreasing without def/class
106- " (don't change the def/class pattern even if you change the others!)
102+ " (don't change this def/class pattern even if you change the others!)
107103 elseif ind>0 && ind>= indent (a: lnum- 1 ) && getline (a: lnum- 1 )!~ ' ^$\|^\s*\(def\|class\)\s'
108104 return ' ='
109105 " - empty lines before non-global lines
0 commit comments