Skip to content

Commit 3f4fc36

Browse files
committed
solved gh issue #814 (on the folding jumping problem)
1 parent 67d3426 commit 3f4fc36

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

autoload/pymode/folding.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ endfunction "}}}
4646

4747
fun! pymode#folding#expr(lnum) "{{{
4848

49-
return pymode#folding#foldcase(a:lnum)['foldlevel']
49+
let l:return_value = pymode#folding#foldcase(a:lnum)['foldlevel']
50+
51+
return l:return_value
5052

5153
endfunction "}}}
5254

@@ -138,9 +140,7 @@ fun! pymode#folding#foldcase(lnum) "{{{
138140
let line_block_start = s:BlockStart(a:lnum)
139141
let line_block_end = s:BlockEnd(a:lnum)
140142
let prev_line_block_start = s:BlockStart(a:lnum - 1)
141-
let save_cursor = getcurpos()
142143
if line !~ s:blank_regex
143-
call setpos('.', save_cursor)
144144
if line_block_start == prev_line_block_start
145145
\ || a:lnum - line_block_start == 1
146146
let l:foldcase = 'non blank line; first line of block or part of it'

ftplugin/python/pymode.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,30 @@ endif
5454

5555
" Python folding
5656
if g:pymode_folding
57+
" On the folding problem.
58+
" =======================
59+
" What happens when your enter insert mode with fdm=expr:
60+
" TODO:
61+
"
62+
" What happens when your leave insert mode and trigger fdm=expr:
63+
" TODO:
5764

5865
setlocal foldmethod=expr
5966
setlocal foldexpr=pymode#folding#expr(v:lnum)
6067
setlocal foldtext=pymode#folding#text()
6168

69+
70+
au! pymode InsertEnter *.py setlocal foldmethod=manual
71+
au! pymode InsertLeave *.py let s:save_winview = winsaveview()
72+
73+
au pymode InsertLeave *.py let s:save_cursor = getcurpos()
74+
au pymode InsertLeave *.py set nofoldenable
75+
au pymode InsertLeave *.py setlocal foldmethod=expr
76+
au pymode InsertLeave *.py set foldenable
77+
au pymode InsertLeave *.py call winrestview(s:save_winview)
78+
au pymode InsertLeave *.py call setpos('.', s:save_cursor)
79+
au pymode InsertLeave *.py call winrestview(s:save_winview)
80+
6281
endif
6382

6483
" Remove unused whitespaces

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