NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.39k stars 13.61k forks source link

[23.05-unstable] tmux + vim paste bug #215881

Open abyxcos opened 1 year ago

abyxcos commented 1 year ago

Describe the bug

When running vim inside of tmux and attempting to system paste in insert mode (middle click, shift insert, apple-v, etc) the paste event becomes prefixed with control/escape characters. I have only been able to test this behavior with Apple's Terminal.app sshed in to a nixos machine.

  1. Pasting in to ssh works (no vim, no tmux).

  2. Pasting in vim without tmux works.

  3. Pasting in a bash shell in a tmux window works.

  4. Pasting in to a bash shell executed from vim (:sh command) inside tmux works.

  5. Pasting in to vim running in tmux fails.

Additional context

This only occurs on the 23.05-unstable branch. This works as expected on 22.11. This occurs with both the default vim config and the below config.

cat ~/.vimrc
set nocompatible
set bs=indent,eol,start
set rulerformat=%=%l,%v\ %p%%

syntax off
set hlsearch

Sample file before paste:

a
b
c

[copy the text "https://github.com/NixOS/nixpkgs"] 2Ga " go to second line and enter append mode [press shift-insert]

New file contents:

a
b://github.com/NixOS/nixpkgs
c

Notify maintainers

Vim: @dasJ @equirosa Tmux: @tobias-hammerschmidt @fpletz @SuperSandro2000 @rapenne-s

Metadata

abyxcos commented 1 year ago

I cannot replicate this via a UART serial terminal to the machine, so ssh/sshd may be involved?

FlorianFranzen commented 1 year ago

I started having the same issue on unstable with foot and vim under wayland (sway). It is not an issue if I ssh into any of my other hosts, but they also do not run on unstable. (:set paste makes no difference either.)

hxtmdev commented 1 month ago

I had a problem involving escape delays in tmux+vim recently, try fiddling with the timeout settings of tmux and vim and see if that brings new info.

See https://www.johnhawthorn.com/2012/09/vi-escape-delays/

Overall this smells like a race condition, just brainstorming here but maybe: