fix(picker.actions): use vim.v.register instead of + as default.

This commit is contained in:
Folke Lemaitre 2025-02-10 20:47:29 +01:00
parent 6f88b1ced9
commit 9ab6637df0
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 6 additions and 4 deletions

View file

@ -86,7 +86,7 @@ function M.actions.explorer_yank(_, item)
if not item then
return
end
vim.fn.setreg("+", item.file)
vim.fn.setreg(vim.v.register or "+", item.file)
Snacks.notify.info("Yanked `" .. item.file .. "`")
end

View file

@ -432,7 +432,7 @@ end
function M.yank(picker, item, action)
---@cast action snacks.picker.yank.Action
if item then
local reg = action.reg or "+"
local reg = action.reg or vim.v.register
local value = item[action.field] or item.data or item.text
vim.fn.setreg(reg, value)
local buf = item.buf or vim.api.nvim_win_get_buf(picker.main)
@ -442,10 +442,12 @@ function M.yank(picker, item, action)
end
M.copy = M.yank
function M.put(picker, item)
function M.put(picker, item, action)
---@cast action snacks.picker.yank.Action
picker:close()
if item then
vim.api.nvim_put({ item.data or item.text }, "c", true, true)
local value = item[action.field] or item.data or item.text
vim.api.nvim_put({ value }, "", true, true)
end
end