summaryrefslogtreecommitdiff
path: root/src/normal.c
diff options
context:
space:
mode:
authorShougo Matsushita <Shougo.Matsu@gmail.com>2022-01-28 16:01:13 +0000
committerBram Moolenaar <Bram@vim.org>2022-01-28 16:01:13 +0000
commitfb55207ed17918c8a2a6cadf5ad9d5fcf686a7ab (patch)
tree9faeac58af548281bea9b0f703bd2cbbdb96c380 /src/normal.c
parent420fabcd4ffeaf79082a6e43db91e1d363f88f27 (diff)
downloadvim-git-fb55207ed17918c8a2a6cadf5ad9d5fcf686a7ab.tar.gz
patch 8.2.4242: put in Visual mode cannot be repeatedv8.2.4242
Problem: Put in Visual mode cannot be repeated. Solution: Use "P" to put without yanking the deleted text into the unnamed register. (Shougo Matsushita, closes #9591)
Diffstat (limited to 'src/normal.c')
-rw-r--r--src/normal.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/normal.c b/src/normal.c
index 2d5f8a5f7..412700ae1 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -4661,8 +4661,8 @@ nv_bracket_block(cmdarg_T *cap, pos_T *old_pos)
}
// found start/end of other method: go to match
else if ((pos = findmatchlimit(cap->oap, findc,
- (cap->cmdchar == '[') ? FM_BACKWARD : FM_FORWARD,
- 0)) == NULL)
+ (cap->cmdchar == '[') ? FM_BACKWARD : FM_FORWARD,
+ 0)) == NULL)
n = 0;
else
curwin->w_cursor = *pos;
@@ -7505,6 +7505,8 @@ 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;
if (cap->oap->op_type != OP_NOP)
{
@@ -7551,6 +7553,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';
#ifdef FEAT_CLIPBOARD
adjust_clip_reg(&regname);
#endif
@@ -7568,6 +7571,11 @@ 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;
@@ -7577,6 +7585,12 @@ nv_put_opt(cmdarg_T *cap, int fix_indent)
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;