copy/paste garbage while using mc, due to lack of support of bracketed paste mode

Bug #1350334 reported by Fuujuhi
104
This bug affects 21 people
Affects Status Importance Assigned to Milestone
vte (Ubuntu)
Fix Committed
Undecided
Unassigned

Bug Description

Gnome terminator does not support bracketed paste mode introduced by xterm to detect between typed-in text and text that is copy-pasted.

Due to this, copy-pasting text in terminator adds some garbage character before and after pasted text.

This bug occurs on latest version (from bzr).

Example:

   my_pasted_text

becomes

  0~my_paster_text1~

This occurs when using Terminator along with Midnight Commander.

This is a well known bug that has been fixed already in Gnome Terminal.
Apparently the bug has been fixed in VTE, and as a result on Gnome Terminal.
See references below for details.

To trigger the bug, see sequence below, copied from referenced bug report:

1) start gnome-terminal
2) start mc in that terminal
3) enter the Ctrl-o subshell
4) maximise the terminal (in terminator, this is same as doing for instance Ctrl-Z to maximize current sub-window)
5) leave the Ctrl-o subshell (i.e. return to the dir/file list)
6) copy some text (e.g. some "filename")
7) return back to the Ctrl-o subshell
8) paste the text

References:
- xterm bracketed paste mode
http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Bracketed%20Paste%20Mode
- original bug report on Midnight Commander
http://www.midnight-commander.org/ticket/3207
- Bug fix and patch on VTE
https://bugzilla.gnome.org/show_bug.cgi?id=729533

Tags: patch
Revision history for this message
Fuujuhi (fuujuhi) wrote :

Just for google search: so this is garbage/extra tilde characters when copy-paste in terminator.

Also I'm using Ubuntu Trusty 14.04, but as said bugs appears in latest version from bzr anyway.

Revision history for this message
Fuujuhi (fuujuhi) wrote :

One can disable bracketed paste mode by doing in the terminal where bug occurs:

printf "\e[?2004l"

Not very convenient, but at least you don't have to close your terminal, and open a new one.

Reference:
- bracketed paste mode
http://cirw.in/blog/bracketed-paste

Revision history for this message
Fuujuhi (fuujuhi) wrote :

Just notice that the bug also occurs in gnome-terminal in Trusty.
So apparently the copy paste bug is not fixed at all in Trusty, although it seems to be fixed in debian.

Revision history for this message
Fuujuhi (fuujuhi) wrote :

Ok, add "vte" source package because the bug is there apparently.
(Not sure about all the metadata things above, please fix/tell how to fix if necessary)

It has been reported and fixed already on Gnome bugzilla:

https://bugzilla.gnome.org/show_bug.cgi?id=729533

Nerijus Baliunas pushed a patch on vte 0.28.2.

Here I attach a backport on trusty version, ie. 0.28.2-5ubuntu1.
Patch is in git format, but I guess easy to apply.

This patch fixes the issue above in terminator, gnome terminal, etc.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Backport of Nerijus' patch for bracketed paste mode on 0.28.2-5ubuntu1" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Egmont Koblinger (egmont-gmail) wrote :

The mentioned terminals do support bracketed paste mode - but do it incorrectly. If they didn't support it all, you wouldn't see the bug.

The *real* problem here is Terminator using a 3 year old unmaintained version of vte (bug 1030562). The bracketed paste issue is just a manifestation of this core problem.

Vte received at least a hundred bugfixes since then (including data corruptions, crashes etc.), the bracketed paste mode fix not being anywhere near the most important ones. IMO it doesn't make too much sense to backport this single patch, it's a very bad use of developers' time. Instead, Terminator, Xfce4-terminal and any other Gtk2 terminal apps should be ported to Gtk3/vte3.

Revision history for this message
Fuujuhi (fuujuhi) wrote :

I understand the logic behind your comment, but on the other hand the patch is a very simple one and it fixes a really annoying bug that occurs very frequently for anyone using midnight commander (and whatever console app enabling bracketed mode I guess). If I see the bug you referred to, it has been filed in 2012, and apparently it's a long way to go before release. Note that the bracketed mode bug also occurs in Gnome Terminal. Will it be fixed there as well if bug 1030562 is fixed? At least the patch attached here fixes it for Gnome Terminal as well.

My feeling is that Trusty LTS is a nice release, but it is still unpolished because of bugs like this one. My hope is that these small annoyances get fixed rapidly. Will we have to work around this bug for months if not years while waiting for the right thing to be done?

Revision history for this message
Egmont Koblinger (egmont-gmail) wrote :

Gnome-terminal (actually vte) has fixed this issue and this fix will appear in Utopic. If Terminator finally updated their code to Gtk3 (which apparently nobody is working on), it would also automatically get the fix.

In my experiences, it's very hard to get Ubuntu folks pay attention to bugs like this. Unless there's a critical bug (and, unfortunately, often even if it is a critical one), the way to get it fixed in Ubuntu is to fix mainstream and wait for the distro to catch up.

> My feeling is that Trusty LTS is a nice release, but it is still unpolished because of bugs like this one.

Only vte alone has ~170 open bugs upstream (some of them are dups or invalid or feature requests, but still), and plenty more that were fixed recently and are missing from legacy vte (gtk2) that you're using. This is one component of the thousands that are shipped by Ubuntu. This pasting bug might be your pet peeve, but is probably of very low priority for others.

> occurs very frequently for anyone using midnight commander (and whatever console app enabling bracketed mode I guess)

No, no.

The bug is related to Midnight Commander constantly switching back and forth between the normal and the alternate screens (the one where its panels are shown and has no scrollbar) and is triggered by a special sequence of actions. If, for one, you don't use Ctrl+O, you won't face the bug while bracketed paste still works correctly in the editor.

In other apps, e.g. vim, you can use bracketed pasting, probably without ever facing the bug.

Revision history for this message
Egmont Koblinger (egmont-gmail) wrote :

You might want to check the progress I made in bug 1030562 porting terminator to gtk3. It would be cool if you could step up and finish that work, or find someone to do that.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in vte (Ubuntu):
status: New → Confirmed
Revision history for this message
ATIpro (somebody2112) wrote :

I'm also affected by this bug. I've seen that in lxterminal and xfce4-terminal. Will it be fixed in Trusty?

ATIpro (somebody2112)
no longer affects: lxterminal (Ubuntu)
Revision history for this message
ATIpro (somebody2112) wrote :

And gnome-terminal is also affected, so there is not much choices of terminal emulators without this bug. This is one of my biggest issues with Trusty.

Revision history for this message
Eugene (eugene-kiev) wrote :

I'm using Ubuntu 14.04 and have this bug in gnome-terminal as with running mc, so without it.

Revision history for this message
Egmont Koblinger (egmont-gmail) wrote :

To everyone suffering from this bug:

You could maybe - as a terrible workaround - disable "bracketed paste mode" from your shell prompt. In case of bash, you might want to alter your PS1 to contain
$'... \[\e[?2004l\] ...'
or set PROMPT_COMMAND to echo $'\e[?2004l'.

When pressing ^O to return to the subshell in mc, you might need to press Enter once for the prompt to get printed, but then at least you can copy without those extra character. Also, probably you won't see bracketed paste's advantages when copying text into mc's built-in editor.

Revision history for this message
Fuujuhi (fuujuhi) wrote :

I would say *terrifying* work around ;-) Otherwise, good tip.

But to me, the point is that the bug is an annoyance for all systems I touch. Of course, this ^O thing (or similar) is part of my own process, so not everybody is concerned, but every time I come to a new system, I get it, I have to patch it (or work around it), when it would be much simpler to get it fixed in the repo.

Now, I still agree that your proposal about fixing the bug where it belongs (i.e. migrate GT to use the new VTE) is the best. But honestly, I had a quick look, and although I have some dev skills, this is much beyond me for now. Too many kids at home, not enough time. Also, I'm not sure that even if GT would be migrated to VTE 3, that it would be pushed to 14.04.

The easiest for me would be to get the patch above pushed into VTE 2 in the repo. You say that VTE 2 is unmaintained. But is there any chance still we can get the patch pushed to the report? What is the process to get this done? Should I contact anybody?

Revision history for this message
Fuujuhi (fuujuhi) wrote :

I meant "get the patch pushed to the *repo*?"

Revision history for this message
Egmont Koblinger (egmont-gmail) wrote :

> Also, I'm not sure that even if GT would be migrated to VTE 3, that it would be pushed to 14.04.

I'm absolutely sure it wouldn't. (It has a preliminary vte3 version, with many remaining bugs, but you might want to give that a try.) Someone might create an unofficial repo for this package, though.

> The easiest for me would be to get the patch above pushed into VTE 2 in the
> repo. You say that VTE 2 is unmaintained. But is there any chance still we
> can get the patch pushed to the repo? What is the process to get this done?
> Should I contact anybody?

I don't know whom to contact, sorry. You'd need to find someone in the Ubuntu team willing to patch vte2 and backport it to trusty. I hardly see any chance for this to happen, there are plenty of way more serious bugs going unnoticed/unfixed by Ubuntu developers. Maybe someone in the community would be happy to bring up a separate repository containing this bugfix, you could try to ask for help on various Ubuntu forums.

That's why I recommended the shell prompt hack, that's probably your best bet now.

(A note about the abbreviation you use: Terminator (the vte2-based app) as far as I know doesn't have the word "Gnome" in its name, yet you refer to it as Gnome Terminator, abbreviated with GT, which is damn easy to be confused with the vte3-based standard Gnome Terminal. To avoid confusion, I recommend to spell out "Terminator" or "Gnome Terminal" in this ticket.)

Revision history for this message
Fuujuhi (fuujuhi) wrote :

Ok, thanks for the info.

Sorry for the confusion. I meant indeed Terminator. I got used to say gnome-terminator because that was the original name of Tenshu's ppa. But the real package name is "Terminator".

But note that the bug is also present in "Gnome Terminal" (as per #3 above). Just tried again now, and the bug is there (although I have the patched vte for GTK2, but indeed this has no effect since Gnome Terminal uses libvte-2.90-9, which GTK+ 3.0).

Revision history for this message
hda_launchpad (hda-me) wrote :

gnome-terminal 3.6.2-0ubuntu1
libvte-2.90-9
All on trusty. Bug is very annoying and still here.

Revision history for this message
GreyBox (grey-box) wrote :

Also: ubuntu 15.10 + xfce 4.12.0 + xfce4-terminal 0.6.3

Put command reset in terminal helps.

Revision history for this message
Eugene San (eugenesan) wrote :

Backport to Trusty "Bracketed paste should be per-terminal" patch (LP: #1350334)

Changed in terminator:
status: New → Invalid
Changed in vte (Ubuntu):
status: Confirmed → Fix Committed
Mathew Hodson (mhodson)
affects: terminator → ubuntu
no longer affects: ubuntu
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.