mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.1.2302: :lockmarks does not work for '[ and ']
Problem: :lockmarks does not work for '[ and ']. Solution: save and restore '[ and '] marks. (James McCoy, closes #5222)
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user