gbprod / yanky.nvim

Improved Yank and Put functionalities for Neovim
Do What The F*ck You Want To Public License
802 stars 22 forks source link

[Error] Occurs with `cancel_event = 'move'` When Pasting Twice #154

Closed tummetott closed 8 months ago

tummetott commented 8 months ago

Hello,

When I set cancle_event = 'move' and I paste twice with yanky, the plugin throws an error.

Reproduce:

  1. Copy paste this minimal conf mini.lua:
    
    local lazypath = "/tmp/lazy/lazy.nvim"
    if not vim.loop.fs_stat(lazypath) then
    vim.fn.system { "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath }
    end
    vim.opt.rtp:prepend(lazypath)
    vim.opt.termguicolors = true

require("lazy").setup ({ { "gbprod/yanky.nvim", opts = { ring = { cancel_event = 'move', }, } }, }, { root = "/tmp/lazy" })

vim.keymap.set({"n","x"}, "p", "(YankyPutAfter)") vim.keymap.set({"n","x"}, "P", "(YankyPutBefore)") vim.keymap.set({"n","x"}, "gp", "(YankyGPutAfter)") vim.keymap.set({"n","x"}, "gP", "(YankyGPutBefore)") vim.keymap.set("n", "", "(YankyCycleForward)") vim.keymap.set("n", "", "(YankyCycleBackward)") vim.keymap.set({"n","x"}, "y", "(YankyYank)")

2. Run: `nvim --clean -u mini.lua`
3. Press: `i` --> `hallo` --> `ESC` --> `yiw` (write hallo and yank the word)
4. Press: `p` --> `p` (paste twice)

### Error message:

Error executing vim.schedule lua callback: /tmp/lazy/yanky.nvim/lua/yanky.lua:125: attempt to index field 'state' (a nil value) stack traceback: /tmp/lazy/yanky.nvim/lua/yanky.lua:125: in function </tmp/lazy/yanky.nvim/lua/yanky.lua:124>

gbprod commented 8 months ago

Thanks for this issue report, I think I've foud a fix #156 :) I'll merge it soon, Let me know if it's ok for you

tummetott commented 8 months ago

Amazing thank you for the fix