0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 8.2.4881: "P" in Visual mode still changes some registers

Problem:    "P" in Visual mode still changes some registers.
Solution:   Make "P" in Visual mode not change any register. (Shougo
            Matsushita, closes #10349)
This commit is contained in:
Shougo Matsushita
2022-05-06 11:45:09 +01:00
committed by Bram Moolenaar
parent 434725cc4c
commit 509142ab7a
6 changed files with 83 additions and 52 deletions

View File

@@ -7236,8 +7236,7 @@ nv_put_opt(cmdarg_T *cap, int fix_indent)
int was_visual = FALSE;
int dir;
int flags = 0;
int save_unnamed = FALSE;
yankreg_T *old_y_current, *old_y_previous;
int keep_registers = FALSE;
if (cap->oap->op_type != OP_NOP)
{
@@ -7284,7 +7283,7 @@ nv_put_opt(cmdarg_T *cap, int fix_indent)
// overwrites if the old contents is being put.
was_visual = TRUE;
regname = cap->oap->regname;
save_unnamed = cap->cmdchar == 'P';
keep_registers = cap->cmdchar == 'P';
#ifdef FEAT_CLIPBOARD
adjust_clip_reg(&regname);
#endif
@@ -7302,26 +7301,15 @@ nv_put_opt(cmdarg_T *cap, int fix_indent)
}
// Now delete the selected text. Avoid messages here.
if (save_unnamed)
{
old_y_current = get_y_current();
old_y_previous = get_y_previous();
}
cap->cmdchar = 'd';
cap->nchar = NUL;
cap->oap->regname = NUL;
cap->oap->regname = keep_registers ? '_' : NUL;
++msg_silent;
nv_operator(cap);
do_pending_operator(cap, 0, FALSE);
empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
--msg_silent;
if (save_unnamed)
{
set_y_current(old_y_current);
set_y_previous(old_y_previous);
}
// delete PUT_LINE_BACKWARD;
cap->oap->regname = regname;