Skip to content

Commit a8dcbc8

Browse files
committed
improved folding of various cases
1 parent 72bbe35 commit a8dcbc8

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

autoload/pymode/folding.vim

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ fun! s:BlockStart(lnum) "{{{
200200

201201
" Now find the class/def one shiftwidth lower than the start of the
202202
" aforementioned indent block.
203-
if next_stmt_at_def_indent && a:lnum <= next_stmt_at_def_indent
203+
if next_stmt_at_def_indent && next_stmt_at_def_indent < a:lnum
204204
let max_indent = max([indent(next_stmt_at_def_indent) - &shiftwidth, 0])
205205
else
206206
let max_indent = max([indent(prevnonblank(a:lnum)) - &shiftwidth, 0])
@@ -211,14 +211,6 @@ endfunction "}}}
211211
fun! s:BlockEnd(lnum) "{{{
212212
" Note: Make sure to reset cursor position after using this function.
213213
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
222214
return searchpos('\v^\s{,'.indent('.').'}\S', 'nW')[0] - 1
223215
endfunction "}}}
224216

plugin/pymode.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
" vi: fdl=1
2-
let g:pymode_version = "0.8.1"
2+
let g:pymode_version = "0.9.0"
33

44
com! PymodeVersion echomsg "Current python-mode version: " . g:pymode_version
55
com! PymodeTroubleshooting call pymode#troubleshooting#test()
@@ -39,7 +39,8 @@ call pymode#default("g:pymode_folding", 1)
3939
" Maximum file length to check for nested class/def statements
4040
call pymode#default("g:pymode_folding_nest_limit", 1000)
4141
" Change for folding customization (by example enable fold for 'if', 'for')
42-
call pymode#default("g:pymode_folding_regex", '^\s*\%(class\|def\) \w\+')
42+
call pymode#default("g:pymode_folding_regex", '^\s*\%(class\|def\|async\s\+def\) .\+\(:\s\+\w\)\@!')
43+
4344

4445
" Enable/disable python motion operators
4546
call pymode#default("g:pymode_motion", 1)
@@ -314,4 +315,3 @@ endif
314315
command! PymodeVersion echomsg "Pymode version: " . g:pymode_version . " interpreter: " . g:pymode_python . " lint: " . g:pymode_lint . " rope: " . g:pymode_rope
315316

316317
augroup pymode
317-

0 commit comments

Comments
 (0)