Skip to content

fix(#2535): TextYankPost event sends vim.v.event #2734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 31, 2024

Conversation

zyd2001
Copy link
Contributor

@zyd2001 zyd2001 commented Mar 31, 2024

Try to fix issue #2535 (comment) that I also encountered.

I write the data to a temporary buffer and use vim 'y' command to do real yank to trigger TextYankPost event with correct v:event.

Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, although it fails on gy and friends:

E5108: Error executing lua: ...er/start/zyd2001/lua/nvim-tree/actions/fs/copy-paste.lua:290: Error executing lua: ...er/start/zyd2001/lua/nvim-tree/actions/fs/copy-paste.lua:291: bad argument #2 to 'format' (number expected, got string)
stack traceback:
        [C]: in function 'format'
        ...er/start/zyd2001/lua/nvim-tree/actions/fs/copy-paste.lua:291: in function <...er/start/zyd2001/lua/nvim-tree/actions/fs/copy-paste.lua:290>
        [C]: in function 'nvim_buf_call'
        ...er/start/zyd2001/lua/nvim-tree/actions/fs/copy-paste.lua:290: in function 'copy_to_clipboard'
        ...er/start/zyd2001/lua/nvim-tree/actions/fs/copy-paste.lua:300: in function 'fn'
        .../nd/site/pack/packer/start/zyd2001/lua/nvim-tree/api.lua:65: in function <.../nd/site/pack/packer/start/zyd2001/lua/nvim-tree/api.lua:62>
stack traceback:
        [C]: in function 'nvim_buf_call'
        ...er/start/zyd2001/lua/nvim-tree/actions/fs/copy-paste.lua:290: in function 'copy_to_clipboard'
        ...er/start/zyd2001/lua/nvim-tree/actions/fs/copy-paste.lua:300: in function 'fn'
        .../nd/site/pack/packer/start/zyd2001/lua/nvim-tree/api.lua:65: in function <.../nd/site/pack/packer/start/zyd2001/lua/nvim-tree/api.lua:62>

Clean room with

vim.api.nvim_create_autocmd("TextYankPost", {
  callback = function(data)
    log.line("dev", "TextYankPost\ndata=%s\nevent=%s", vim.inspect(data), vim.inspect(vim.v.event))
  end,
})

@zyd2001
Copy link
Contributor Author

zyd2001 commented Mar 31, 2024

Should be working now, used wrong format string.

@alex-courtis alex-courtis changed the title Fix TextYankPost event fix(#2535): TextYankPost event sends vim.v.event Mar 31, 2024
Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for your contribution!

@alex-courtis alex-courtis merged commit d8d3a15 into nvim-tree:master Mar 31, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants