diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-07-01 15:47:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-01 15:47:21 +0200 |
commit | a50a3a12d6dc877e63cc5645c68e15c512517ffb (patch) | |
tree | 363d0f219cece22fa513ddeb14e6a4c554887db5 | |
parent | f35a5f2efc32b508ff5fc7d55b31a5bb7facfa17 (diff) | |
parent | 47a08ec72ed27ef0ba2519865ebcedf9f62abe8e (diff) | |
download | rneovim-a50a3a12d6dc877e63cc5645c68e15c512517ffb.tar.gz rneovim-a50a3a12d6dc877e63cc5645c68e15c512517ffb.tar.bz2 rneovim-a50a3a12d6dc877e63cc5645c68e15c512517ffb.zip |
Merge pull request #14848 from shadmansaleh/fixup/block_paste_clipboard
fix(clipboard): Fix block paste from system clipboard not working properly
-rw-r--r-- | runtime/autoload/provider/clipboard.vim | 12 | ||||
-rw-r--r-- | test/functional/provider/clipboard_spec.lua | 14 |
2 files changed, 25 insertions, 1 deletions
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index 07f37d604f..dea79f21f0 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -156,7 +156,14 @@ function! s:clipboard.get(reg) abort elseif s:selections[a:reg].owner > 0 return s:selections[a:reg].data end - return s:try_cmd(s:paste[a:reg]) + + let clipboard_data = s:try_cmd(s:paste[a:reg]) + if match(&clipboard, '\v(unnamed|unnamedplus)') >= 0 && get(s:selections[a:reg].data, 0, []) == clipboard_data + " When system clipboard return is same as our cache return the cache + " as it contains regtype information + return s:selections[a:reg].data + end + return clipboard_data endfunction function! s:clipboard.set(lines, regtype, reg) abort @@ -175,6 +182,9 @@ function! s:clipboard.set(lines, regtype, reg) abort if s:cache_enabled == 0 call s:try_cmd(s:copy[a:reg], a:lines) + "Cache it anyway we can compare it later to get regtype of the yank + let s:selections[a:reg] = copy(s:selection) + let s:selections[a:reg].data = [a:lines, a:regtype] return 0 end diff --git a/test/functional/provider/clipboard_spec.lua b/test/functional/provider/clipboard_spec.lua index 2c681eb9d8..e5e21f11a6 100644 --- a/test/functional/provider/clipboard_spec.lua +++ b/test/functional/provider/clipboard_spec.lua @@ -506,6 +506,20 @@ describe('clipboard (with fake clipboard.vim)', function() feed('p') eq('textstar', meths.get_current_line()) end) + + it('Block paste works currectly', function() + insert([[ + aabbcc + ddeeff + ]]) + feed('gg^<C-v>') -- Goto start of top line enter visual block mode + feed('3ljy^k') -- yank 4x2 block & goto initial location + feed('P') -- Paste it infront + expect([[ + aabbaabbcc + ddeeddeeff + ]]) + end) end) describe('clipboard=unnamedplus', function() |