File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,9 @@ endfunction "}}}
46
46
47
47
fun ! pymode#folding#expr (lnum) " {{{
48
48
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
50
52
51
53
endfunction " }}}
52
54
@@ -138,9 +140,7 @@ fun! pymode#folding#foldcase(lnum) "{{{
138
140
let line_block_start = s: BlockStart (a: lnum )
139
141
let line_block_end = s: BlockEnd (a: lnum )
140
142
let prev_line_block_start = s: BlockStart (a: lnum - 1 )
141
- let save_cursor = getcurpos ()
142
143
if line !~ s: blank_regex
143
- call setpos (' .' , save_cursor)
144
144
if line_block_start == prev_line_block_start
145
145
\ || a: lnum - line_block_start == 1
146
146
let l: foldcase = ' non blank line; first line of block or part of it'
Original file line number Diff line number Diff line change @@ -54,11 +54,30 @@ endif
54
54
55
55
" Python folding
56
56
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:
57
64
58
65
setlocal foldmethod = expr
59
66
setlocal foldexpr = pymode#folding#expr (v: lnum )
60
67
setlocal foldtext = pymode#folding#text ()
61
68
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
+
62
81
endif
63
82
64
83
" Remove unused whitespaces
You can’t perform that action at this time.
0 commit comments