l-zeuch/yagpdb.vim

Clipboard Register Broken

Closed this issue · 1 comments

Expected Behaviour

The buffer's content is properly written to the system clipboard with the :YagCopy command.

Actual Behaviour

Instead, nothing is written to the system clipboard.

Steps to Reproduce

  • Write something
  • run :YagCopy
  • Paste whatever content is in your clipboard (ctrl + V)
  • See error

Additional Context

$ nvim --version
NVIM v0.6.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info
$ Xorg -version
X.Org X Server 1.21.1.3
X Protocol Version 11, Revision 0
Current Operating System: Linux 5.16.7-arch1-1 #1 SMP PREEMPT Tue, 01 Feb 2022 21:42:50 +0000 x86_64
Kernel command line: BOOT_IMAGE=/vmlinuz-linux root=UUID=659b7f90-bb02-4c6e-b3a4-af7daf2b11d3 rw rootflags=subvol=root quiet loglevel=3 udev.log-priority=3 splash vt.global_cursor_default=0
 
Current version of pixman: 0.40.0
	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.

Presumably something might be not quite right with my Neovim installation, however I noticed that the "* register is labelled as X11 primary, whereas "+ is labelled as X11 clipboard -- both however have the description "clipboard"; see also this handy cheatsheet.

Thus, I am not quite sure how to write a patch for this, let me know your thoughts -- perhaps attempting to write to both registers, or finding out which one actually works consistently, and going with that instead?. I doubt it is an issue with upstream Neovim and Xorg, though.

Additionally, I noticed that "+ works as expected.

Code of Conduct

  • I agree to follow this project's Code of Conduct.

This was one of the confusing aspects of X11 for me, when I switched to Linux. As you noticed, it has two clipboards — PRIMARY (Vim's "* register) and CLIPBOARD ("+).

In terms of resolution, we could certainly just brute-force it by setting both registers, or use a configuration variable (say, g:YagUseQuotePlus or something) to decide which register to set. I personally like the latter option, since it means we won't blow away the contents of both clipboards if the user doesn't expect it.

Another note: most clipboard managers give you the ability to sync the two clipboards. My concern there would be making sure that we don't add duplicate entries to the user's clipboard history by setting both registers. I can test this, as I use CopyQ, a clipboard manager with history tracking.

(On Windows, both "* and "+ write to the singular clipboard, so any changes we make here shouldn't affect Windows users.)