diff options
-rw-r--r-- | src/nvim/ops.c | 17 | ||||
-rw-r--r-- | test/functional/clipboard/clipboard_provider_spec.lua | 6 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 54c2edf4fa..1ed6827a33 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -775,9 +775,12 @@ void get_yank_register(int regname, int mode) { int i; + if (mode == YREG_PASTE && get_clipboard(regname, &y_current, false)) { + // y_current is set to clipboard contents. + return; + } y_append = FALSE; - int unnamedclip = cb_flags & CB_UNNAMEDMASK; - if ((regname == 0 || regname == '"') && !unnamedclip && mode != YREG_YANK && y_previous != NULL) { + if ((regname == 0 || regname == '"') && mode != YREG_YANK && y_previous != NULL) { y_current = y_previous; return; } @@ -801,8 +804,6 @@ void get_yank_register(int regname, int mode) if (mode == YREG_YANK) { // remember the written register for unnamed paste y_previous = y_current; - } else if (mode == YREG_PASTE) { - get_clipboard(regname, &y_current, false); } } @@ -5366,11 +5367,11 @@ static struct yankreg* adjust_clipboard_name(int *name, bool quiet, bool writing return NULL; } -static void get_clipboard(int name, struct yankreg** target, bool quiet) +static bool get_clipboard(int name, struct yankreg** target, bool quiet) { struct yankreg* reg = adjust_clipboard_name(&name, quiet, false); if (reg == NULL) { - return; + return false; } free_register(reg); @@ -5455,7 +5456,7 @@ static void get_clipboard(int name, struct yankreg** target, bool quiet) } *target = reg; - return; + return true; err: if (reg->y_array) { @@ -5467,6 +5468,8 @@ err: reg->y_array = NULL; reg->y_size = 0; EMSG("clipboard: provider returned invalid data"); + *target = reg; + return false; } static void set_clipboard(int name) diff --git a/test/functional/clipboard/clipboard_provider_spec.lua b/test/functional/clipboard/clipboard_provider_spec.lua index 10a346b8ba..c5d8f57008 100644 --- a/test/functional/clipboard/clipboard_provider_spec.lua +++ b/test/functional/clipboard/clipboard_provider_spec.lua @@ -55,6 +55,12 @@ local function basic_register_test(noblock) , stuff and some more some textsome some text, stuff and some more]]) + -- deleting a line does update "" + feed('ggdd""P') + expect([[ + , stuff and some more + some textsome some text, stuff and some more]]) + feed('ggw<c-v>jwyggP') if noblock then expect([[ |