Commit a1022442 authored by Ahmad Samir's avatar Ahmad Samir
Browse files

Don't add extra newlines when pasting from GTK applications

Due to some internal handling in GTK itself, we end up with text copied
from Firefox where a newline is represented as CRLF (\r\n); since the
doPaste() method replaces each \n with \r, we ended up with \r\r, which
ultimately led to extra newlines in the pasted code. To fix the issue
simply detect the CRLF case and replace each \r\n with \r.

To test, copy some multiline text from Firefox, open vim in konsole and
paste, you end up with two newlines between each block of text. Compare the
results after applying this patch

BUG: 421480
FIXED-IN: 20.08
parent 57c942d9
......@@ -3274,6 +3274,10 @@ void TerminalDisplay::doPaste(QString text, bool appendReturn)
if (!text.isEmpty()) {
// replace CRLF with CR first, fixes issues with pasting multiline
// text from gtk apps (e.g. Firefox), bug 421480
text.replace(QLatin1String("\r\n"), QLatin1String("\r"));
text.replace(QLatin1Char('\n'), QLatin1Char('\r'));
if (bracketedPasteMode()) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment