ojroques / nvim-osc52

A Neovim plugin to copy text through SSH with OSC52
BSD 2-Clause "Simplified" License
350 stars 12 forks source link

One interesting bug with tmux after updating #35

Closed marsjane closed 5 months ago

marsjane commented 6 months ago

I am using this function for quite some time to let the content copied by yy go to system clipboard, even when I ssh and use tmux, it works fine:

local function copy()
  if vim.v.event.operator == "y" and (vim.v.event.regname == "" or vim.v.event.regname == "+") then
    require("osc52").copy_register("+")
  end
end
vim.api.nvim_create_autocmd("TextYankPost", { callback = copy })

However, recently after I update all plugins, I found it only works in tmux if I modify require("osc52").copy_register("+") to require("osc52").copy_register(""), if I use old function, it works when use vim directly in ssh, but it won't work when I use nvim in ssh - tmux, I am not sure about the reason, any ideas about this? Also, what's the difference if I do this modification? What I can see is that, same config, in macOS, the system clipboard will totally the same with the neovim register when I use 'dd', but in linux they are different

ojroques commented 6 months ago

Hello!

See :h registers for the difference between the two registers.

Unnamed register ""
Vim fills this register with text deleted with the "d", "c", "s", "x" commands
or copied with the yank "y" command, regardless of whether or not a specific
register was used (e.g.  "xdd).
Selection registers "* and "+
Use these registers for storing and retrieving the selected text for the GUI. When the clipboard is not available or not working, the unnamed register is used instead.

So I guess your clipboard is no more available, that's why it uses the "" register instead.

ojroques commented 5 months ago

I'm closing this issue, feel free to reopen it if you still have issues.