mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
clipboard: don't overwrite before pasting in visual mode. #2945
This occured when clipboard=unnamedplus and doing "+p in visual mode. Fixes #2942.
This commit is contained in:
parent
0ffd51425e
commit
e9c9d44f65
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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' */
|
||||
|
@ -253,6 +253,12 @@ describe('clipboard usage', function()
|
||||
feed("viwp")
|
||||
eq({{'visual'}, 'v'}, eval("g:test_clip['*']"))
|
||||
expect("indeed clipboard")
|
||||
|
||||
-- explicit "* should do the same
|
||||
execute("let g:test_clip['*'] = [['star'], 'c']")
|
||||
feed('viw"*p')
|
||||
eq({{'clipboard'}, 'v'}, eval("g:test_clip['*']"))
|
||||
expect("indeed star")
|
||||
end)
|
||||
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user