1
0
forked from aniani/vim

patch 8.0.0581: moving folded text is sometimes not correct

Problem:    Moving folded text is sometimes not correct.
Solution:   Bail out when "move_end" is zero. (Matthew Malcomson)
This commit is contained in:
Bram Moolenaar
2017-04-22 22:40:11 +02:00
parent f1d21c8cc8
commit 94be619e30
3 changed files with 61 additions and 22 deletions

View File

@@ -3133,10 +3133,14 @@ foldMoveRange(garray_T *gap, linenr_T line1, linenr_T line2, linenr_T dest)
dest_index = fold_index(fp, gap);
/*
* All folds are now correct, but they are not necessarily in the correct
* order. We have to swap folds in the range [move_end, dest_index) with
* those in the range [move_start, move_end).
* All folds are now correct, but not necessarily in the correct order. We
* must swap folds in the range [move_end, dest_index) with those in the
* range [move_start, move_end).
*/
if (move_end == 0)
/* There are no folds after those moved, hence no folds have been moved
* out of order. */
return;
foldReverseOrder(gap, (linenr_T)move_start, (linenr_T)dest_index - 1);
foldReverseOrder(gap, (linenr_T)move_start,
(linenr_T)(move_start + dest_index - move_end - 1));