feat(picker.undo): added ctrl+y to yank added lines from undo

This commit is contained in:
Folke Lemaitre 2025-02-07 10:21:18 +01:00
parent bc087d36d6
commit 811a24cc16
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 18 additions and 3 deletions

View file

@ -421,9 +421,14 @@ function M.loclist(picker)
setqflist(items, { win = picker.main })
end
function M.yank(_, item)
function M.yank(picker, item, action)
if item then
vim.fn.setreg("+", item.data or item.text)
local reg = action.reg or "+"
local value = item.data or item.text
vim.fn.setreg(reg, value)
local buf = item.buf or vim.api.nvim_win_get_buf(picker.main)
local ft = vim.bo[buf].filetype
Snacks.notify(("Yanked to register `%s`:\n```%s\n%s\n```"):format(reg, ft, value), { title = "Snacks Picker" })
end
end
M.copy = M.yank