summaryrefslogtreecommitdiffstats
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-11-16 13:50:25 +0100
committerBram Moolenaar <Bram@vim.org>2019-11-16 13:50:25 +0100
commitf4a1d1c0542df151bc59ac3b798ed198b5c71ccc (patch)
tree9f6051c5c5e75c7f113a923f7888f0f272ddee9e /src/ex_cmds.c
parentab85ca4e6a40b2998db7b00896505486f5c16b41 (diff)
patch 8.1.2302: :lockmarks does not work for '[ and ']v8.1.2302
Problem: :lockmarks does not work for '[ and ']. Solution: save and restore '[ and '] marks. (James McCoy, closes #5222)
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r--src/ex_cmds.c68
1 files changed, 49 insertions, 19 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index c15bbc5f4c..5615adcaa5 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -749,8 +749,11 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
foldMoveRange(&win->w_folds, line1, line2, dest);
}
#endif
- curbuf->b_op_start.lnum = dest - num_lines + 1;
- curbuf->b_op_end.lnum = dest;
+ if (!cmdmod.lockmarks)
+ {
+ curbuf->b_op_start.lnum = dest - num_lines + 1;
+ curbuf->b_op_end.lnum = dest;
+ }
}
else
{
@@ -761,10 +764,14 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
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;
+ if (!cmdmod.lockmarks)
+ {
+ 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;
+ if (!cmdmod.lockmarks)
+ curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
mark_adjust_nofold(last_line - num_lines + 1, last_line,
-(last_line - dest - extra), 0L);
@@ -813,9 +820,12 @@ ex_copy(linenr_T line1, linenr_T line2, linenr_T n)
char_u *p;
count = line2 - line1 + 1;
- curbuf->b_op_start.lnum = n + 1;
- curbuf->b_op_end.lnum = n + count;
- curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
+ if (!cmdmod.lockmarks)
+ {
+ curbuf->b_op_start.lnum = n + 1;
+ curbuf->b_op_end.lnum = n + count;
+ curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
+ }
/*
* there are three situations:
@@ -1055,10 +1065,17 @@ do_filter(
char_u *cmd_buf;
buf_T *old_curbuf = curbuf;
int shell_flags = 0;
+ pos_T orig_start = curbuf->b_op_start;
+ pos_T orig_end = curbuf->b_op_end;
+ int save_lockmarks = cmdmod.lockmarks;
if (*cmd == NUL) /* no filter command */
return;
+ // Temporarily disable lockmarks since that's needed to propagate changed
+ // regions of the buffer for foldUpdate(), linecount, etc.
+ cmdmod.lockmarks = 0;
+
cursor_save = curwin->w_cursor;
linecount = line2 - line1 + 1;
curwin->w_cursor.lnum = line1;
@@ -1287,11 +1304,18 @@ error:
filterend:
+ cmdmod.lockmarks = save_lockmarks;
if (curbuf != old_curbuf)
{
--no_wait_return;
emsg(_("E135: *Filter* Autocommands must not change current buffer"));
}
+ else if (cmdmod.lockmarks)
+ {
+ curbuf->b_op_start = orig_start;
+ curbuf->b_op_end = orig_end;
+ }
+
if (itmp != NULL)
mch_remove(itmp);
if (otmp != NULL)
@@ -3276,13 +3300,16 @@ ex_append(exarg_T *eap)
* eap->line2 pointed to the end of the buffer and nothing was appended)
* "end" is set to lnum when something has been appended, otherwise
* it is the same than "start" -- Acevedo */
- curbuf->b_op_start.lnum = (eap->line2 < curbuf->b_ml.ml_line_count) ?
- eap->line2 + 1 : curbuf->b_ml.ml_line_count;
- if (eap->cmdidx != CMD_append)
- --curbuf->b_op_start.lnum;
- curbuf->b_op_end.lnum = (eap->line2 < lnum)
- ? lnum : curbuf->b_op_start.lnum;
- curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
+ if (!cmdmod.lockmarks)
+ {
+ curbuf->b_op_start.lnum = (eap->line2 < curbuf->b_ml.ml_line_count) ?
+ eap->line2 + 1 : curbuf->b_ml.ml_line_count;
+ if (eap->cmdidx != CMD_append)
+ --curbuf->b_op_start.lnum;
+ curbuf->b_op_end.lnum = (eap->line2 < lnum)
+ ? lnum : curbuf->b_op_start.lnum;
+ curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
+ }
curwin->w_cursor.lnum = lnum;
check_cursor_lnum();
beginline(BL_SOL | BL_FIX);
@@ -4592,10 +4619,13 @@ outofmem:
if (sub_nsubs > start_nsubs)
{
- /* Set the '[ and '] marks. */
- curbuf->b_op_start.lnum = eap->line1;
- curbuf->b_op_end.lnum = line2;
- curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
+ if (!cmdmod.lockmarks)
+ {
+ // Set the '[ and '] marks.
+ curbuf->b_op_start.lnum = eap->line1;
+ curbuf->b_op_end.lnum = line2;
+ curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
+ }
if (!global_busy)
{