Oni: `set clipboard=unnamed` and duplicating the line

Created on 30 May 2018  路  11Comments  路  Source: onivim/oni


First of all let me thank all the team for working on it! I was surprised how smoothly it runs and handles my current nvim configuration almost without exceptions.

Oni Version: 0.3.4
Neovim Version (Linux only):
Operating System: MacOS Sierra 10.12.2

Describe your issue

Yp shortcut is broken when oni.loadInitVim is set to true and init.vim contains the set clipboard=unnamed line.

Steps to reproduce

Create the minimal oni-test-init.vim containing just this:

set clipboard=unnamed

Specify the configuration setting in the config.tsx as following:

...
"oni.loadInitVim": "/path/to/oni-test-init.vim"
...

Restart Oni. In any text editing window:

  1. Go to Insert mode (i)
  2. Type "test" (test)
  3. Go back to normal mode (Esc)
  4. Duplicate the line (Yp or yyp)

Expected behaviour

test

Actual behaviour


The issue is not critical. There is a workaround:

if !exists("g:gui_oni")
  set clipboard=unnamed
endif

But very annoying when you hit it for the first time.

Once again thank you for working on it!

Most helpful comment

Got a private branch with a fix, will post a PR soon.

All 11 comments

Hello and welcome to the Oni repository! Thanks for opening your first issue here. To help us out, please make sure to include as much detail as possible - including screenshots and logs, if possible.

Hi, @zindel !

Thanks for logging this!
Personally, I suffered with this issue up until now and kept wishing it to be fixed.
Just tried your solution and it seems to work great!

@bryphe, do you think Oni should handle it on boot?
I think of something like:

if ((clipboard == 'unnamed' || clipboard == 'unnamedplus') &&
    SOME_USER_CONFIG_THAT_DEFAULT_TO_TRUE) {
    clipboard = '' // I think that this is the default value
}

Well, after a day of work w/o set clipboard=unnamedplus I am at a loss.
This setting is a life-quality requirement, but so is the the validity of yyp, yyP, ddP etc.

Anyone has an idea of how to fix this so that both will work at the same time?

@TalAmuyal what is the problem you are getting? Selection works well for me inside Oni & the console nvim as well. I am on MacOS though

I use Mac too.

The issue is thus:

If I set clipboard to unnamedplus then

  1. The system-clipboard and the default vim-register are the same and thus I can <CMD-C> in Google Chrome and p in Oni
  2. I have the same issue that you described at the beginning of this thread.

On the other hand, if I remove the setting of clipboard then

  1. I loose the ability to freely copy-paste between Oni and the rest of the OS
  2. Line-wise copy-paste inside Oni works as expected.

I want both having "line-wise copy-paste inside Oni work as expected" and "the ability to freely copy-paste between Oni and the rest of the OS".

So, just verified on my own, here is what I am getting:

  1. If I do :set clipboard in Oni, I get clipboard=
  2. Copying from Oni to other windows (for example, Chrome)

    • Y in Oni

    • Cmd+V in Chrome Works!

  3. Copying from Chrome to Oni

    • Select text and Cmd+C in Chrome

    • Normal mode in Oni, p Doesn't work, getting the context of the last deleted line in Oni

    • Insert mode in Oni, Cmd+V Works! Getting content of the Chrome selection

So, the issue exists, but as usually, there is a workaround :)

Just tried setting "editor.clipboard.enabled": false, in Oni's config and it seems to work fine with set clipboard=unnamedplus.
Will give it a try for a work-day or two and will report back.

Glad there is a workaround! Let me know if that doesn't work, @TalAmuyal . And thanks for the kind words and thoughtful investigation, @zindel !

I'm guessing that there is some interplay here:
https://github.com/onivim/oni/blob/a34e1d64ecf529f2d31f5f0bbb9cc33c4d19980e/browser/src/Editor/NeovimEditor/NeovimEditor.tsx#L423

When editor.clipboard.enabled is true, Oni on yank will set the clipboard directly. It might be that it's not properly passing up a new line or paving the clipboard. A potential fix might be to ditch this behavior if the user explicitly sets clipboard - if a user explicitly sets clipboard, we can assume they know exactly what behavior they want.

The only downside is there is a complicated interplay of settings between editor.clipboard.enabled and set clipboard - perhaps there is a way we could streamline this or make it more intuitive?

Got a private branch with a fix, will post a PR soon.

PR: https://github.com/onivim/oni/pull/2298
Will appreciate feedback for for the code-change and for actual functionality :)

Should be fixed now in master.
Please note if there are more inconsistencies.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

phaazon picture phaazon  路  21Comments

justinmk picture justinmk  路  22Comments

rococode picture rococode  路  20Comments

badosu picture badosu  路  20Comments

hboon picture hboon  路  21Comments