Skip to content

Commit 54b2bfa

Browse files
committed
patch 8.0.0136
Problem: When using indent folding and changing indent the wrong fold is opened. (Jonathan Fudger) Solution: Open the fold under the cursor a bit later. (Christian Brabandt)
1 parent ded2782 commit 54b2bfa

3 files changed

Lines changed: 40 additions & 5 deletions

File tree

src/ops.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,6 @@ op_shift(oparg_T *oap, int curs_top, int amount)
259259
}
260260

261261
changed_lines(oap->start.lnum, 0, oap->end.lnum + 1, 0L);
262-
#ifdef FEAT_FOLDING
263-
/* The cursor line is not in a closed fold */
264-
foldOpenCursor();
265-
#endif
266-
267262
if (oap->block_mode)
268263
{
269264
curwin->w_cursor.lnum = oap->start.lnum;
@@ -277,6 +272,12 @@ op_shift(oparg_T *oap, int curs_top, int amount)
277272
else
278273
--curwin->w_cursor.lnum; /* put cursor on last line, for ":>" */
279274

275+
#ifdef FEAT_FOLDING
276+
/* The cursor line is not in a closed fold */
277+
foldOpenCursor();
278+
#endif
279+
280+
280281
if (oap->line_count > p_report)
281282
{
282283
if (oap->op_type == OP_RSHIFT)

src/testdir/test_fold.vim

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,35 @@ function! Test_address_fold()
6363

6464
quit!
6565
endfunction
66+
67+
function! Test_indent_fold()
68+
new
69+
call setline(1, ['', 'a', ' b', ' c'])
70+
setl fen fdm=indent
71+
2
72+
norm! >>
73+
let a=map(range(1,4), 'foldclosed(v:val)')
74+
call assert_equal([-1,-1,-1,-1], a)
75+
endfu
76+
77+
function! Test_indent_fold()
78+
new
79+
call setline(1, ['', 'a', ' b', ' c'])
80+
setl fen fdm=indent
81+
2
82+
norm! >>
83+
let a=map(range(1,4), 'foldclosed(v:val)')
84+
call assert_equal([-1,-1,-1,-1], a)
85+
bw!
86+
endfu
87+
88+
function! Test_indent_fold2()
89+
new
90+
call setline(1, ['', '{{{', '}}}', '{{{', '}}}'])
91+
setl fen fdm=marker
92+
2
93+
norm! >>
94+
let a=map(range(1,5), 'foldclosed(v:val)')
95+
call assert_equal([-1,-1,-1,4,4], a)
96+
bw!
97+
endfu

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
136,
767769
/**/
768770
135,
769771
/**/

0 commit comments

Comments
 (0)