Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#1027435: ncurses-base: Breaks pasting in vim within tmux

94 views
Skip to first unread message

Antoine Le Gonidec

unread,
Dec 31, 2022, 8:40:04 AM12/31/22
to
Package: ncurses-base
Version: 6.3+20221224-2
Severity: important

Since the 6.3+20221224-2 update, vim pasting behaviour is broken when
TERM is set to "tmux" or "tmux-256color".

To reproduce it, open vim, type a few word, then try to copy/paste them
using selection then middle mouse clic, or Ctrl + Shift + C then Ctrl +
Shift + V. The pasting then has a strange behaviour, it looks like vim
automatically goes back to edition mode (instead of insertion mode) at
the beginning of the paste process, then treat the following characters
as commands (so it will go back to insertion mode at the first "i", "a"
or "s").

This issue does not happen outside of tmux, or if TERM is set to "xterm"
instead of "tmux". Reverting to ncurses-base 6.3+20220423-2 is another
way to work around this unexpected behaviour.

-- System Information:
Debian Release: bookworm/sid
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'testing-debug'), (500, 'stable-debug'), (500, 'oldstable-debug'), (500, 'unstable'), (500, 'testing'), (500, 'stable'), (500, 'oldstable'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.0.0-6-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

-- no debconf information

Thomas Dickey

unread,
Dec 31, 2022, 9:00:04 AM12/31/22
to
On Sat, Dec 31, 2022 at 02:18:49PM +0100, Antoine Le Gonidec wrote:
> Package: ncurses-base
> Version: 6.3+20221224-2
> Severity: important

that's probably this - which will be in today's update/release:

--- ncurses-6.3-20221224+/misc/terminfo.src 2022-12-24 18:18:58.000000000 +0000
+++ ncurses-6.4-20221231/misc/terminfo.src 2022-12-29 20:11:56.000000000 +0000
@@ -6,8 +6,8 @@
# Report bugs and new terminal descriptions to
# bug-n...@gnu.org
#
-# $Revision: 1.1039 $
-# $Date: 2022/12/24 18:18:58 $
+# $Revision: 1.1041 $
+# $Date: 2022/12/29 20:11:56 $
#
# The original header is preserved below for reference. It is noted that there
# is a "newer" version which differs in some cosmetic details (but actually
@@ -5768,7 +5768,7 @@
# detail. The names for the extended capabilities here were introduced by vim
# in January 2017.
bracketed+paste|xterm bracketed paste,
- BD=\E[?2004l, BE=\E[?2004h, PD=\E[201~, PE=\E[200~,
+ BD=\E[?2004l, BE=\E[?2004h, PE=\E[201~, PS=\E[200~,

#### XTERM Mouse
# The xterm mouse protocol is used by other terminal emulators.
@@ -8210,7 +8210,7 @@
use=screen4,

no+brackets|cancel bracketed paste,
- BD@, BE@, PD@, PE@,
+ BD@, BE@, PE@, PS@,

# The bce and status-line entries are from screen 3.9.13 (and require some
# changes to .screenrc).
@@ -25508,8 +25508,8 @@
#
# BE enables bracketed paste
# BD disables bracketed paste
-# PE is sent before the pasted text
-# PD is sent after the pasted text
+# PS is sent before the pasted text
+# PE is sent after the pasted text
#
# Here are the other xterm-related extensions which are used in this file:
#
@@ -27713,4 +27713,8 @@
# + add/use bracketed+paste to help identify terminals supporting this
# xterm feature (prompted by discussion with Bram Moolenaar) -TD
#
+# 2022-12-29
+# + correct PS vs PE names in bracketed+paste (report by Bram Moolenaar)
+# -TD
+#
######## SHANTIH! SHANTIH! SHANTIH!

--
Thomas E. Dickey <dic...@invisible-island.net>
https://invisible-island.net
signature.asc

Sven Joachim

unread,
Jan 1, 2023, 8:30:04 AM1/1/23
to
Unfortunately, this did not help here :-(. After upgrading ncurses-base
to 6.4-1, pasting text into vim running inside tmux still gives the same
funny behavior the submitter described in the original report here,
tested on unstable with vim 9.0.1000 and tmux 3.3a.

Bram Moolenaar published patch 9.0.1117[1] the other day. I have not
tested yet whether it makes a difference, but the commit message
("Correct mixup of output strings and key codes.") sounds like it might
fix the issue.

Cheers,
Sven


1. https://github.com/vim/vim/commit/7b8db111e819bcb07cff6fc451584b0e3e0a49fd

Sven Joachim

unread,
Jan 1, 2023, 11:50:03 AM1/1/23
to
Indeed applying patch 9.0.1117 fixes the problem, provided that
ncurses-base is /also/ upgraded to 6.4-1. With the incorrect
definitions from ncurses-base 6.3+20221224-1, pasting remains broken
even in vim 9.0.1117.

So I guess we need to clone a copy of this bug to vim and upgrade both
ncurses and vim.

Cheers,
Sven

Sven Joachim

unread,
Jan 1, 2023, 12:30:04 PM1/1/23
to
Control: clone -1 -2
Control: reassign -2 vim
Control: retitle -2 vim: bracketed paste is broken before patch 9.0.1117

Notice to the vim maintainers: #1027435 has a few more messages you
might want to read for background.

On 2022-12-31 14:18 +0100, Antoine Le Gonidec wrote:

> Package: ncurses-base
> Version: 6.3+20221224-2
> Severity: important
>
> Since the 6.3+20221224-2 update, vim pasting behaviour is broken when
> TERM is set to "tmux" or "tmux-256color".
>
> To reproduce it, open vim, type a few word, then try to copy/paste them
> using selection then middle mouse clic, or Ctrl + Shift + C then Ctrl +
> Shift + V. The pasting then has a strange behaviour, it looks like vim
> automatically goes back to edition mode (instead of insertion mode) at
> the beginning of the paste process, then treat the following characters
> as commands (so it will go back to insertion mode at the first "i", "a"
> or "s").
>
> This issue does not happen outside of tmux, or if TERM is set to "xterm"
> instead of "tmux". Reverting to ncurses-base 6.3+20220423-2 is another
> way to work around this unexpected behaviour.

Thanks for the report. This is due to a feature introduced in the ncurses
Christmas patchlevel:

,----
| 20221224
| + add/use bracketed+paste to help identify terminals supporting this
| xterm feature (prompted by discussion with Bram Moolenaar) -TD
`----

That turned out to be botched and has been corrected in yesterday's
patchlevel (incidentally, also the ncurses 6.4 release):

,----
| 20221231 6.4 release for upload to ftp.gnu.org
| + correct PS vs PE names in bracketed+paste (report by Bram Moolenaar)
| -TD
`----

So far so good, and I have already prepared ncurses 6.4-1 in git. Now
the bad news: it turned out that bracketed paste support in vim had
(always?) been broken without anybody noticing it, because no terminal
descriptions had included this feature. Only two days ago Bram
Moolenaar fixed the problem in patch 9.0.1117[1].

I have backported this patch to the debian/sid branch in vim's git
repository and can confirm that it fixes the problem, as long as
ncurses-base is also upgraded to version 6.4-1.

Sven Joachim

unread,
Jan 1, 2023, 1:00:03 PM1/1/23
to
Control: tags -1 fixed-upstream patch
Control: forwarded -1 https://github.com/vim/vim/issues/11766

On 2023-01-01 18:25 +0100, Sven Joachim wrote:

> So far so good, and I have already prepared ncurses 6.4-1 in git. Now
> the bad news: it turned out that bracketed paste support in vim had
> (always?) been broken without anybody noticing it, because no terminal
> descriptions had included this feature. Only two days ago Bram
> Moolenaar fixed the problem in patch 9.0.1117[1].

> I have backported this patch to the debian/sid branch in vim's git
> repository and can confirm that it fixes the problem, as long as
> ncurses-base is also upgraded to version 6.4-1.

See the attached patch which I used as the last one in the series file.
If you want to reorder it so that it comes before the 9.0.1118 backport,
you need to edit the src/version.c hunks in both patches so that they
apply cleanly.

There has also been some discussion in the upstream issue #11766,
although that is rather confusing as some people had the ncurses
20221224 patchlevel installed and not upgraded to the corrected ncurses
6.4 release. In this case, no vim patch would help (see #1027435).

Cheers,
Sven

patch-9.0.1117-terminfo-entries-for-bracketed-paste.patch

James McCoy

unread,
Jan 1, 2023, 4:00:03 PM1/1/23
to
On Sun, Jan 01, 2023 at 06:54:10PM +0100, Sven Joachim wrote:
> Control: tags -1 fixed-upstream patch
> Control: forwarded -1 https://github.com/vim/vim/issues/11766
>
> On 2023-01-01 18:25 +0100, Sven Joachim wrote:
>
> > So far so good, and I have already prepared ncurses 6.4-1 in git. Now
> > the bad news: it turned out that bracketed paste support in vim had
> > (always?) been broken without anybody noticing it, because no terminal
> > descriptions had included this feature. Only two days ago Bram
> > Moolenaar fixed the problem in patch 9.0.1117[1].
>
> > I have backported this patch to the debian/sid branch in vim's git
> > repository and can confirm that it fixes the problem, as long as
> > ncurses-base is also upgraded to version 6.4-1.
>
> See the attached patch which I used as the last one in the series file.
> If you want to reorder it so that it comes before the 9.0.1118 backport,
> you need to edit the src/version.c hunks in both patches so that they
> apply cleanly.

Thanks for the info and patch. Do you happen to know if the patched Vim
will work properly with the older ncurses (thinking of partial
upgrades)? Or should ncurses Break older vim versions?

Cheers,
--
James
GPG Key: 4096R/91BF BF4D 6956 BD5D F7B7 2D23 DFE6 91AE 331B A3DB

Sven Joachim

unread,
Jan 1, 2023, 4:40:03 PM1/1/23
to
On 2023-01-01 15:54 -0500, James McCoy wrote:

> On Sun, Jan 01, 2023 at 06:54:10PM +0100, Sven Joachim wrote:
>> Control: tags -1 fixed-upstream patch
>> Control: forwarded -1 https://github.com/vim/vim/issues/11766
>>
>> On 2023-01-01 18:25 +0100, Sven Joachim wrote:
>>
>> > So far so good, and I have already prepared ncurses 6.4-1 in git. Now
>> > the bad news: it turned out that bracketed paste support in vim had
>> > (always?) been broken without anybody noticing it, because no terminal
>> > descriptions had included this feature. Only two days ago Bram
>> > Moolenaar fixed the problem in patch 9.0.1117[1].
>>
>> > I have backported this patch to the debian/sid branch in vim's git
>> > repository and can confirm that it fixes the problem, as long as
>> > ncurses-base is also upgraded to version 6.4-1.
>>
>> See the attached patch which I used as the last one in the series file.
>> If you want to reorder it so that it comes before the 9.0.1118 backport,
>> you need to edit the src/version.c hunks in both patches so that they
>> apply cleanly.
>
> Thanks for the info and patch. Do you happen to know if the patched Vim
> will work properly with the older ncurses (thinking of partial
> upgrades)?

It should work the same way as before.

> Or should ncurses Break older vim versions?

I suppose so. First we would need a fixed vim in testing, though.

Cheers,
Sven

Sven Joachim

unread,
Jan 11, 2023, 1:00:04 PM1/11/23
to
On 2023-01-01 18:25 +0100, Sven Joachim wrote:

> So far so good, and I have already prepared ncurses 6.4-1 in git. Now
> the bad news: it turned out that bracketed paste support in vim had
> (always?) been broken without anybody noticing it, because no terminal
> descriptions had included this feature. Only two days ago Bram
> Moolenaar fixed the problem in patch 9.0.1117[1].
>
> I have backported this patch to the debian/sid branch in vim's git
> repository and can confirm that it fixes the problem, as long as
> ncurses-base is also upgraded to version 6.4-1.

James was so kind to upload this fix the next day, and so things have
been fine in unstable since then. However Bookworm is still broken,
with vim currently unable to migrate because of vim-ultisnips'
autopkgtest failure in #1028442.

Once the fixed vim migrates to testing I intent to add versioned Breaks
on vim-common to ncurses-base and ncurses-term, so that users do not
experience the problem on partial upgrades from Bullseye, and close the
current bug.

Cheers,
Sven

Sven Joachim

unread,
Jan 22, 2023, 2:40:04 PM1/22/23
to
Control: tags -1 pending
Vim has migrated to testing today (according to rmadison,
tracker.debian.org seems to be a bit behind), so I added the versioned
Breaks in git[1]. This should have sent out a mail which marks the bug
as pending and informs the submitter, but for some unknown reason it
didn't. Anyway, good to see that things have been sorted out by now.

Cheers,
Sven


1. https://salsa.debian.org/debian/ncurses/-/commit/12bb87e58cf0ad787b90281452404a9ee1240244

王昊然

unread,
Feb 15, 2023, 12:40:04 AM2/15/23
to
This 'fix' unnecessarily broke the dependency of my VIM 7.4 packages, which
aren't affected by this bug.
0 new messages