8000 Add file length limit for checking for nested folds · python-mode/python-mode@09dc5ef · GitHub
[go: up one dir, main page]

Skip to content

Commit 09dc5ef

Browse files
committed
Add file length limit for checking for nested folds
1 parent 5304abe commit 09dc5ef

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

autoload/pymode/folding.vim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ fun! pymode#folding#expr(lnum) "{{{
5757
return "<".(indent / &shiftwidth + 1)
5858
endif
5959

60-
" Handle nested defs
61-
if indent(prevnonblank(a:lnum))
60+
" Handle nested defs but only for files shorter than
61+
" g:pymode_folding_nest_limit lines due to performance concerns
62+
if line('$') < g:pymode_folding_nest_limit && indent(prevnonblank(a:lnum))
6263
let curpos = getcurpos()
6364
try
6465
let last_block = s:BlockStart(a:lnum)

plugin/pymode.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ call pymode#default("g:pymode_indent", 1)
3636

3737
" Enable/disable pymode folding for pyfiles.
3838
call pymode#default("g:pymode_folding", 1)
39+
" Maximum file length to check for nested class/def statements
40+
call pymode#default("g:pymode_folding_nest_limit", 1000)
3941
" Change for folding customization (by example enable fold for 'if', 'for')
4042
call pymode#default("g:pymode_folding_regex", '^\s*\%(class\|def\) \w\+')
4143

0 commit comments

Comments
 (0)
0