mirror of
https://github.com/neovim/neovim
synced 2025-07-28 09:21:58 +00:00
fix(clipboard): enable cache for function providers #34470
Problem:
With these settings, copy/pasting `blockwise-visual` (with `CTRL+V`)
incorrectly pastes as a `linewise` mode because `regtype` is ignored:
vim.opt.clipboard = 'unnamedplus'
vim.g.clipboard = 'osc52'
To reproduce: press `CTRL+V` and select some characters press `p` and
observe that it is pasted in `linewise` mode.
Solution:
Enable the [clipboard.vim](https://github.com/neovim/neovim/blob/master/runtime/autoload/provider/clipboard.vim#L281-L283))
cache for function providers, so that `regtype` is maintained for the OSC52
clipboard provider.
(cherry picked from commit ac12dc49cc
)
This commit is contained in:
committed by
github-actions[bot]
parent
d0a24ea03e
commit
77eb278adf
@ -268,13 +268,11 @@ function! provider#clipboard#Executable() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:clipboard.get(reg) abort
|
function! s:clipboard.get(reg) abort
|
||||||
if type(s:paste[a:reg]) == v:t_func
|
if s:selections[a:reg].owner > 0
|
||||||
return s:paste[a:reg]()
|
|
||||||
elseif s:selections[a:reg].owner > 0
|
|
||||||
return s:selections[a:reg].data
|
return s:selections[a:reg].data
|
||||||
end
|
end
|
||||||
|
|
||||||
let clipboard_data = s:try_cmd(s:paste[a:reg])
|
let clipboard_data = type(s:paste[a:reg]) == v:t_func ? s:paste[a:reg]() : s:try_cmd(s:paste[a:reg])
|
||||||
if match(&clipboard, '\v(unnamed|unnamedplus)') >= 0
|
if match(&clipboard, '\v(unnamed|unnamedplus)') >= 0
|
||||||
\ && type(clipboard_data) == v:t_list
|
\ && type(clipboard_data) == v:t_list
|
||||||
\ && get(s:selections[a:reg].data, 0, []) ==# clipboard_data
|
\ && get(s:selections[a:reg].data, 0, []) ==# clipboard_data
|
||||||
@ -294,13 +292,12 @@ function! s:clipboard.set(lines, regtype, reg) abort
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if type(s:copy[a:reg]) == v:t_func
|
if s:cache_enabled == 0 || type(s:copy[a:reg]) == v:t_func
|
||||||
call s:copy[a:reg](a:lines, a:regtype)
|
if type(s:copy[a:reg]) == v:t_func
|
||||||
return 0
|
call s:copy[a:reg](a:lines, a:regtype)
|
||||||
end
|
else
|
||||||
|
call s:try_cmd(s:copy[a:reg], a:lines)
|
||||||
if s:cache_enabled == 0
|
endif
|
||||||
call s:try_cmd(s:copy[a:reg], a:lines)
|
|
||||||
"Cache it anyway we can compare it later to get regtype of the yank
|
"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] = copy(s:selection)
|
||||||
let s:selections[a:reg].data = [a:lines, a:regtype]
|
let s:selections[a:reg].data = [a:lines, a:regtype]
|
||||||
|
Reference in New Issue
Block a user