From e9c9d44f6531b4d648c55c235ecf5753a50adf6f Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Fri, 3 Jul 2015 16:02:07 +0200 Subject: clipboard: don't overwrite before pasting in visual mode. #2945 This occured when clipboard=unnamedplus and doing "+p in visual mode. Fixes #2942. --- src/nvim/normal.c | 5 ++++- src/nvim/ops.c | 2 -- src/nvim/option_defs.h | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 7b42467184..92734e404a 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -7278,7 +7278,10 @@ static void nv_put(cmdarg_T *cap) */ was_visual = true; regname = cap->oap->regname; - if (regname == 0 || regname == '"' + // '+' and '*' could be the same selection + bool clipoverwrite = (regname == '+' || regname == '*') + && (cb_flags & CB_UNNAMEDMASK); + if (regname == 0 || regname == '"' || clipoverwrite || ascii_isdigit(regname) || regname == '-') { // The delete might overwrite the register we want to put, save it first savereg = copy_register(regname); diff --git a/src/nvim/ops.c b/src/nvim/ops.c index d8df6ae72d..063ad154f1 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -67,8 +67,6 @@ #define PLUS_REGISTER 38 #define NUM_REGISTERS 39 -#define CB_UNNAMEDMASK (CB_UNNAMED | CB_UNNAMEDPLUS) - static yankreg_T y_regs[NUM_REGISTERS]; static yankreg_T *y_previous = NULL; /* ptr to last written yankreg */ diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 80f2373a85..b13ead9cbb 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -318,6 +318,7 @@ static char *(p_cb_values[]) = {"unnamed", "unnamedplus", NULL}; #endif # define CB_UNNAMED 0x001 # define CB_UNNAMEDPLUS 0x002 +# define CB_UNNAMEDMASK (CB_UNNAMED | CB_UNNAMEDPLUS) EXTERN long p_cwh; /* 'cmdwinheight' */ EXTERN long p_ch; /* 'cmdheight' */ EXTERN int p_confirm; /* 'confirm' */ -- cgit