summaryrefslogtreecommitdiff
path: root/src/fold.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-04-22 22:40:11 +0200
committerBram Moolenaar <Bram@vim.org>2017-04-22 22:40:11 +0200
commit94be619e30e82d28cadeea5e0766c6f5c321ff8b (patch)
treee454f390de5e1e395ea5e260d0748d0db25434b4 /src/fold.c
parentf1d21c8cc83f40c815b6bf13cd2043152db533ee (diff)
downloadvim-git-94be619e30e82d28cadeea5e0766c6f5c321ff8b.tar.gz
patch 8.0.0581: moving folded text is sometimes not correctv8.0.0581
Problem: Moving folded text is sometimes not correct. Solution: Bail out when "move_end" is zero. (Matthew Malcomson)
Diffstat (limited to 'src/fold.c')
-rw-r--r--src/fold.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/fold.c b/src/fold.c
index 8c66b78cd..8f068dccf 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -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));