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)
diff --git a/src/normal.c b/src/normal.c
index e44b513..d8487e6 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -7236,8 +7236,7 @@
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 @@
// 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(®name);
#endif
@@ -7302,26 +7301,15 @@
}
// 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;