@@ -249,7 +249,7 @@ func! Test_move_folds_around_manual()
249249 redraw !
250250 set fdm = manual
251251 call cursor (2 , 1 )
252- norm ! zR
252+ % foldopen
253253 7 ,12 m0
254254 let folds= repeat ([-1 ], 18 )
255255 call assert_equal (PrepIndent (" b" ) + PrepIndent (" a" ) + PrepIndent (" c" ), getline (1 , ' $' ))
@@ -284,6 +284,16 @@ func! Test_move_folds_around_manual()
284284 call assert_equal (0 , foldlevel (6 ))
285285 call assert_equal (9 , foldclosedend (7 ))
286286 call assert_equal ([-1 , 2 , 2 , 2 , 2 , -1 , 7 , 7 , 7 , -1 ], map (range (1 , line (' $' )), ' foldclosed(v:val)' ))
287+ % d
288+ " Ensure moving around the edges still works.
289+ call setline (1 , PrepIndent (" a" ) + repeat ([" a" ], 3 ) + [" \t a" ])
290+ set fdm = indent foldlevel = 0
291+ set fdm = manual
292+ % foldopen
293+ 6 m$
294+ " The first fold has been truncated to the 5'th line.
295+ " Second fold has been moved up because the moved line is now below it.
296+ call assert_equal ([0 , 1 , 1 , 1 , 1 , 0 , 0 , 0 , 1 , 0 ], map (range (1 , line (' $' )), ' foldlevel(v:val)' ))
287297 bw !
288298endfunc
289299
@@ -307,7 +317,7 @@ func! Test_move_folds_around_indent()
307317 call setline (1 , PrepIndent (" a" ) + PrepIndent (" b" ) + PrepIndent (" c" ))
308318 set fdm = indent
309319 call cursor (2 , 1 )
310- norm ! zR
320+ % foldopen
311321 7 ,12 m0
312322 let folds= repeat ([-1 ], 18 )
313323 call assert_equal (PrepIndent (" b" ) + PrepIndent (" a" ) + PrepIndent (" c" ), getline (1 , ' $' ))
@@ -339,5 +349,14 @@ func! Test_move_folds_around_indent()
339349 call assert_equal (1 , foldlevel (6 ))
340350 call assert_equal (9 , foldclosedend (7 ))
341351 call assert_equal ([-1 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , -1 ], map (range (1 , line (' $' )), ' foldclosed(v:val)' ))
352+ " Ensure moving around the edges still works.
353+ % d
354+ call setline (1 , PrepIndent (" a" ) + repeat ([" a" ], 3 ) + [" \t a" ])
355+ set fdm = indent foldlevel = 0
356+ % foldopen
357+ 6 m$
358+ " The first fold has been truncated to the 5'th line.
359+ " Second fold has been moved up because the moved line is now below it.
360+ call assert_equal ([0 , 1 , 1 , 1 , 1 , 0 , 0 , 0 , 1 , 1 ], map (range (1 , line (' $' )), ' foldlevel(v:val)' ))
342361 bw !
343362endfunc
0 commit comments