@@ -8,7 +8,7 @@ let s:def_regex = g:pymode_folding_regex
8
8
let s: blank_regex = ' ^\s*$'
9
9
" Spyder, a very popular IDE for python has a template which includes
10
10
" '@author:' ; thus the regex below.
11
- let s: decorator_regex = ' ^\s*@\(author:\)\@!'
11
+ let s: decorator_regex = ' ^\s*@\(author:\)\@!'
12
12
let s: doc_begin_regex = ' ^\s*[uU]\=\%("""\|'''''' \)'
13
13
let s: doc_end_regex = ' \%("""\|'''''' \)\s*$'
14
14
" This one is needed for the while loop to count for opening and closing
@@ -200,7 +200,7 @@ fun! s:BlockStart(lnum) "{{{
200
200
201
201
" Now find the class/def one shiftwidth lower than the start of the
202
202
" aforementioned indent block.
203
- if next_stmt_at_def_indent && next_stmt_at_def_indent < a: lnum
203
+ if next_stmt_at_def_indent && a: lnum <= next_stmt_at_def_indent
204
204
let max_indent = max ([indent (next_stmt_at_def_indent) - &shiftwidth , 0 ])
205
205
else
206
206
let max_indent = max ([indent (prevnonblank (a: lnum )) - &shiftwidth , 0 ])
@@ -211,6 +211,14 @@ endfunction "}}}
211
211
fun ! s: BlockEnd (lnum) " {{{
212
212
" Note: Make sure to reset cursor position after using this function.
213
213
call cursor (a: lnum , 0 )
214
+ " Regex translation:
215
+ " \v: very magic
216
+ " \s: any space char
217
+ " {...}: zero to more as many as possible
218
+ " \S: non whitespace
219
+ " index [0]: gets the line returned by searchpos
220
+ " flag 'n': do not move cursor
221
+ " flag 'W': don't wrap around the end of the file
214
222
return searchpos (' \v^\s{,' .indent (' .' ).' }\S' , ' nW' )[0 ] - 1
215
223
endfunction " }}}
216
224
@@ -227,7 +235,7 @@ function! s:Is_opening_folding(lnum) "{{{
227
235
for i in range (1 , a: lnum )
228
236
let i_line = getline (i )
229
237
230
- if i_line = ~ s: doc_line_regex
238
+ if i_line = ~ s: doc_line_regex
231
239
" echom "case 00 on line " . i
232
240
continue
233
241
endif
@@ -252,7 +260,7 @@ function! s:Is_opening_folding(lnum) "{{{
252
260
elseif i_line = ~ s: doc_general_regex
253
261
" echom "extra docstrings on line " . i
254
262
let extra_docstrings = extra_docstrings + 1
255
- endif
263
+ endif
256
264
endfor
257
265
258
266
if fmod (number_of_folding, 2 ) == 1 " If odd then it is an opening
0 commit comments