Oni: No carriage return on pasting text

Created on 3 Dec 2017  路  9Comments  路  Source: onivim/oni


I don't know if this relates to my init.vim rather than oni (but I've never noted this issue before or outside oni), on yanking and pasting text, the pasted text does not include a carriage return.
I've tried the default oni config without loading my own config and this still occurs.

When I paste it always goes into the same line as my current line, I think this may relate to copying into the system clipboard which maybe does not include <cr> by default ?

bug needs information

Most helpful comment

Added the following to the wiki you linked:

NOTE: If you have set your g:clipboard to include unnamedplus you will have to disable this inside of Oni as this can lead to issues when pasting with new line characters.

Happy to close this now @bryphe if you're alright with the docs tweak 馃憤

All 9 comments

Strange! Thanks for reporting the issue.

I just tried on OSX, but unfortunately I'm not able to reproduce on my box.

A few questions to try and narrow it down:

  • What kind of file are you using for yanking and pasting? I'm curious especially in terms of the newlines. Also, does it reproduce on a blank / new file?
  • Are you using y and p to paste in normal mode, or are you pasting in insert mode?

We do have some special key bindings for <M-c> and <M-v> set by default, which could potentially behave differently than y + p in normal mode - so knowing which type of paste is occurring would help.

  • Also, is the g:clipboard configuration set? On my config, I didn't have that set, so that could be a potential difference.

Another thing that would be interesting to see, is, in the Oni developer tools, running this:
Oni.editors.activeEditor.neovim.onYank.subscribe((yankInfo) => console.dir(yankInfo)), and then looking at the output after the yank. We should see two lines in regcontents.

@bryphe, this error occurs in every file including new files. This happens using yy and p. yy should take a whole line with a \n but does not work correctly for me.

I've tried deactivating all associated pasting plugins and mappings. pasting from the clipboard does the same thing aka inserts without the \n. My g:clipboard is set to unnamedplus
The problem occurs in insert mode as well as normal mode.

Screenshot following yy command:

screen shot 2017-12-05 at 12 29 47

Thanks for the info, @Akin909 !

this error occurs in every file including new files. This happens using yy and p. yy should take a whole line with a \n but does not work correctly for me.

Strange! For the most part this doesn't reproduce for me - but there was one session I had where I saw the same behavior. Unfortunately, I wasn't able to isolate it.

I wonder if it could be some issue with our TextYankPost autocommand - would you be up for commenting this autogroup and see if it still reproduces, after restarting Oni?
https://github.com/onivim/oni/blob/906880c0ce6dcef8852adae9efe228f88fd31056/vim/core/oni-core-interop/plugin/init.vim#L59

Actually, I just realized, if I execute:

:set clipboard=unnamedplus

I do see the same behavior. I wonder why that is set by default for you, but not for me. Would it be possible to run this?

:verbose set clipboard?

Might give us a clue on where that setting is coming from.

@bryphe easy answer there I'm setting unnamedplus explicitly as a way of telling neovim to always use the system clipboard.
I just disabled it for oni and that works perfectly i.e. resolving my issue. It might warrant a message in docs? (re copy and pasting as I've seen this setting in a quite a few dotfiles) or maybe oni can override this setting since its unnecessary here
actually not sure considering that default vim behaviour is to not copy to the system clipboard and some users might want that functionality, as I personally have gone back and forth on this and its sometimes useful to only have vim save to the clipboard when set explicitly

Ah ok! Yes, it might be worth adding - we have a brief section here: https://github.com/onivim/oni/wiki/Configuration#clipboard-integration

I think that the issue might be interaction between the unnamedplus setting, as well as our behavior with editor.clipboard.enabled set to true (which is the default). Whenever there is a yank, we push it the system clipboard:
https://github.com/onivim/oni/blob/e50500b7a21836dac25e6e15b05c5f4e060cee14/browser/src/Editor/NeovimEditor.tsx#L152

At first I was thinking we could add a trailing newline here - but I realized we would have a hard time differentiating between the yy (whole line) case and just the yank of a word or part of a line, since we just get a string array. Documenting that clipboard+=unnamedplus isn't necessary seems reasonable.

actually not sure considering that default vim behaviour is to not copy to the system clipboard and some users might want that functionality, as I personally have gone back and forth on this and its sometimes useful to only have vim save to the clipboard when set explicitly

Ah ya, it's tough to find the right balance here. We had some discussion in the past in #434 , and we wanted at least a subset of clipboard functionality out-of-the-box in the name of "lower the barrier to entry".

Thats valid, I imagine its a fairly niche audience that would want to restrict access to the clipboard, and the greater majority by far i'm guessing prefer the current out of the box functionality. Re-documentation I can put a line in that section saying that, it shouldn't be set if using oni.

Added the following to the wiki you linked:

NOTE: If you have set your g:clipboard to include unnamedplus you will have to disable this inside of Oni as this can lead to issues when pasting with new line characters.

Happy to close this now @bryphe if you're alright with the docs tweak 馃憤

Awesome, looks great to me @Akin909 ! Thanks for updating the docs!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bfulop picture bfulop  路  3Comments

nwaywood picture nwaywood  路  3Comments

timeyyy picture timeyyy  路  3Comments

Siilwyn picture Siilwyn  路  3Comments

LucianBuzzo picture LucianBuzzo  路  3Comments