summaryrefslogtreecommitdiff
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-03-14 21:53:58 +0100
committerBram Moolenaar <Bram@vim.org>2017-03-14 21:53:58 +0100
commit88d298aed8682eac872ebfe40df3112a6acd83e8 (patch)
tree26123c3b8e8a4bdfae26c82d2eae76ad0bf16f33 /src/ex_cmds.c
parent84be8b66604ef28c0e249284da3c6f0cab1c25ae (diff)
downloadvim-git-88d298aed8682eac872ebfe40df3112a6acd83e8.tar.gz
patch 8.0.0457: using :move messes up manual foldsv8.0.0457
Problem: Using :move messes up manual folds. Solution: Split adjusting marks and folds. Add foldMoveRange(). (neovim patch #6221)
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r--src/ex_cmds.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 64d7f6b84..897730274 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -800,6 +800,8 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
linenr_T last_line; /* Last line in file after adding new text */
#ifdef FEAT_FOLDING
int isFolded;
+ win_T *win;
+ tabpage_T *tp;
/* Moving lines seems to corrupt the folds, delete folding info now
* and recreate it when finished. Don't do this for manual folding, it
@@ -851,24 +853,34 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
* their final destination at the new text position -- webb
*/
last_line = curbuf->b_ml.ml_line_count;
- mark_adjust(line1, line2, last_line - line2, 0L);
- changed_lines(last_line - num_lines + 1, 0, last_line + 1, num_lines);
+ mark_adjust_nofold(line1, line2, last_line - line2, 0L);
if (dest >= line2)
{
- mark_adjust(line2 + 1, dest, -num_lines, 0L);
+ mark_adjust_nofold(line2 + 1, dest, -num_lines, 0L);
+#ifdef FEAT_FOLDING
+ FOR_ALL_TAB_WINDOWS(tp, win) {
+ if (win->w_buffer == curbuf)
+ foldMoveRange(&win->w_folds, line1, line2, dest);
+ }
+#endif
curbuf->b_op_start.lnum = dest - num_lines + 1;
curbuf->b_op_end.lnum = dest;
}
else
{
- mark_adjust(dest + 1, line1 - 1, num_lines, 0L);
+ mark_adjust_nofold(dest + 1, line1 - 1, num_lines, 0L);
+#ifdef FEAT_FOLDING
+ FOR_ALL_TAB_WINDOWS(tp, win) {
+ if (win->w_buffer == curbuf)
+ foldMoveRange(&win->w_folds, dest + 1, line1 - 1, line2);
+ }
+#endif
curbuf->b_op_start.lnum = dest + 1;
curbuf->b_op_end.lnum = dest + num_lines;
}
curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
- mark_adjust(last_line - num_lines + 1, last_line,
+ mark_adjust_nofold(last_line - num_lines + 1, last_line,
-(last_line - dest - extra), 0L);
- changed_lines(last_line - num_lines + 1, 0, last_line + 1, -extra);
/*
* Now we delete the original text -- webb
@@ -907,9 +919,9 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
changed_lines(dest + 1, 0, line1 + num_lines, 0L);
#ifdef FEAT_FOLDING
- /* recreate folds */
- if (isFolded)
- foldUpdateAll(curwin);
+ /* recreate folds */
+ if (isFolded)
+ foldUpdateAll(curwin);
#endif
return OK;