Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting from Windows clipboard to Ubuntu WSL terminal freezes nvim #20396

Open
Et9797 opened this issue Sep 28, 2022 · 10 comments
Open

Pasting from Windows clipboard to Ubuntu WSL terminal freezes nvim #20396

Et9797 opened this issue Sep 28, 2022 · 10 comments
Labels
bug issues reporting wrong behavior clipboard clipboard, paste platform:windows provider

Comments

@Et9797
Copy link

Et9797 commented Sep 28, 2022

Neovim version (nvim -v)

0.8.0-dev (0.8.0ubuntu1+git202209280149-e6c214033-c99271b19-d5ad4b253ubuntu18.04.1)

Vim (not Nvim) behaves the same?

no, vim 0.6.1

Operating system/version

Ubuntu 18.04.5 (WSL 2)

Terminal name/version

Default Ubuntu terminal from the Microsoft store

$TERM environment variable

xterm-256color

Installation

sudo add-apt-repository ppa:neovim-ppa/unstable

How to reproduce the issue

Paste anything into nvim from windows clipboard

Expected behavior

Paste windows clipboard

Actual behavior

Crashes neovim

@Et9797 Et9797 added the bug issues reporting wrong behavior label Sep 28, 2022
@zeertzjq zeertzjq added platform:windows clipboard clipboard, paste bug-crash issue reporting a crash or segfault and removed bug issues reporting wrong behavior labels Sep 28, 2022
@justinmk
Copy link
Member

Paste anything into nvim from windows clipboard

What keys exactly did you use? Is it the system paste, i.e. ctrl-shift-v or ctrl-v ?

@Et9797
Copy link
Author

Et9797 commented Sep 29, 2022

Paste anything into nvim from windows clipboard

What keys exactly did you use? Is it the system paste, i.e. ctrl-shift-v or ctrl-v ?

Right click -> Pasting

https://i.imgur.com/WiWjuK8.png

Ctrl+shift+v paste works fine. In 0.6.1 right click paste works.

@zeertzjq
Copy link
Member

zeertzjq commented Sep 29, 2022

Does pressing "+gP crash?

@Et9797
Copy link
Author

Et9797 commented Sep 29, 2022

Does pressing "+gP crash?

Yes

@Et9797
Copy link
Author

Et9797 commented Sep 29, 2022

Also it's not crashing, it just freezes for a good ~1 minute, and then does not paste the output. I checked if it was anything in my init.vim, but it occurs even with an empty file.

@zeertzjq zeertzjq added bug issues reporting wrong behavior and removed bug-crash issue reporting a crash or segfault labels Sep 29, 2022
@zeertzjq zeertzjq changed the title Pasting from Windows clipboard to Ubuntu WSL terminal crashes nvim Pasting from Windows clipboard to Ubuntu WSL terminal freeze nvim Sep 29, 2022
@zeertzjq zeertzjq changed the title Pasting from Windows clipboard to Ubuntu WSL terminal freeze nvim Pasting from Windows clipboard to Ubuntu WSL terminal freezes nvim Sep 29, 2022
@peienxie
Copy link

peienxie commented Oct 1, 2022

Are you using Window Terminal and xclip?
maybe this relates: microsoft/terminal#11945

I had the same issues before, terminal randomly freezes when pasting from windows to WSL2
I tried to remove xclip and have xsel installed for the last week. I have not experienced this problem.

@georgeanderson
Copy link

I reproduced this in NVIM v0.8.4-dev-2+gb1ae775de and can confirm that installing xsel seemed to have resolved the issue. I don't have xclip, but I also use win23yank.exe per recommend at https://github.com/neovim/neovim/wiki/FAQ#how-to-use-the-windows-clipboard-from-wsl.

@justinmk
Copy link
Member

justinmk commented Mar 9, 2023

installing xsel seemed to have resolved the issue. I don't have xclip, but I also use win23yank.exe per recommend at https://github.com/neovim/neovim/wiki/FAQ#how-to-use-the-windows-clipboard-from-wsl.

Could you try the suggestion given by :help clipboard-wsl ? If that works, I'll update the FAQ to point to that instead. https://neovim.io/doc/user/provider.html#clipboard-wsl

@georgeanderson
Copy link

Yep, it works, but it's very slow. Doesn't seem like a good solution. Having win32yank.exe in the path plus installing xsel "just works". No configuration, and it's fast.

By the way, I had to convert the suggestion to Lua before adding to my config. Let me know if I messed anything up in the process.

vim.g.clipboard = {
  name = 'WslClipboard',
  copy = {
    ['+'] = 'clip.exe',
    ['*'] = 'clip.exe',
  },
  paste = {
    ['+'] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
    ['*'] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
  },
  cache_enabled = 0,
}

My environment:

wsl --version
WSL version: 1.1.3.0
Kernel version: 5.15.90.1
WSLg version: 1.0.49
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19042.2604

uname -a
Linux W109WWSD33 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

nvim --version
NVIM v0.8.4-dev-2+gb1ae775de
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/george/code/hub/neovim/build/cmake.config -I/home/george/code/hub/neovim/src -I/home/george/code/hub/neovim/.deps/usr/include -I/usr/include -I/home/george/code/hub/neovim/build/src/nvim/auto -I/home/george/code/hub/neovim/build/include
Compiled by george@REDACTED

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

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

Run :checkhealth for more info

@afifurrohman-id
Copy link

afifurrohman-id commented May 4, 2024

Yep, it works, but it's very slow. Doesn't seem like a good solution. Having win32yank.exe in the path plus installing xsel "just works". No configuration, and it's fast.

Does win32yank.exe and xsel still works for now?

I can confirm the h: clipboard-wsl work well, but is slow just when paste using right click or p not if using Ctrl-Shift-v.
Ctrl-Shift-v seem still faster and yanked (y) also still faster.

vim.g.clipboard = {
  name = 'WslClipboard',
  copy = {
    ['+'] = 'clip.exe',
    ['*'] = 'clip.exe',
  },
  paste = {
    ['+'] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
    ['*'] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
  },
  cache_enabled = 0,
}

But again, need to add above configuration to work.
Even with that configuration sometimes :%y+ is not work, and i still cannot get the root cause.

My environment:

WSL version: 2.0.14.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22631.3447

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior clipboard clipboard, paste platform:windows provider
Projects
None yet
Development

No branches or pull requests

6 participants