On Sat, Dec 06, 2014 at 05:49:13AM +0100, Bram Moolenaar wrote:
>
> James McCoy wrote:
>
> > Using a Vim that is built to be able to access X's PRIMARY and CLIPBOARD
> > selections (i.e., "* and "+), performing “:let &term=&term” causes Vim
> > to "forget" that it knows how to access those registers.
> >
> > This is because set_termname() ends up calling clip_init(), which sets
> > owned = FALSE on both VimClipboard instances.
> >
> > I'm not sure why changing &term should be modifying the state of the
> > clipboard at all, so the attached patch removes that bit of the code,
> > resolving the bug.
>
> Well, setting the 'term' option sort of means a reset of the terminal.
> Why would you set the 'term' option while something is selected?
This isn't purely about having something selected. Besides, Vim writes
to "* and "+ in cases other than just ":set clipboard=autoselect", so
it's more related to whether Vim has asserted ownership of a specific X
selection and no other app has taken that ownership in the interim.
When one copies something to "+, Vim asserts ownership of the CLIPBOARD
selection. Performing "let &term=&term" makes Vim forget how to access
those registers. This means that the following sequence will result in
unexpected behavior:
In Vim:
"+yy -- Asserts CLIPBOARD ownership with some contents
In some other app:
<C-v> -- Pastes those contents
In Vim:
:let &term=&term
In some other app:
<C-v> -- Doesn't paste anything
Even worse is the reverse:
In some other app:
<C-c> -- copy some text
In Vim:
:let &term=&term
"+p -- The contents of the default register are pasted
To top it off, I haven't yet found a way to make Vim re-realize it can
talk to X, so basically vim (at least from the terminal) is completely
cut off after that code is executed.
Thanks for prodding me to look into the behavior more, as I know feel
even more strongly that the code should be removed.