From b7b037430c07e404143ae084e2ec6733adb8b11e Mon Sep 17 00:00:00 2001 From: Chih-Hsuan Yen Date: Thu, 3 Dec 2020 01:35:35 +0800 Subject: [PATCH] Fix execution after paste when Ctrl is hold --- lib/TerminalDisplay.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index 4e427a8..ce1b3d3 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -2658,12 +2658,19 @@ void TerminalDisplay::emitSelection(bool useXselection,bool appendReturn) // Paste Clipboard by simulating keypress events QString text = QApplication::clipboard()->text(useXselection ? QClipboard::Selection : QClipboard::Clipboard); - if(appendReturn) - text.append(QLatin1Char('\r')); if ( ! text.isEmpty() ) { text.replace(QLatin1Char('\n'), QLatin1Char('\r')); bracketText(text); + + // appendReturn is intentionally handled _after_ enclosing texts with brackets as + // that feature is used to allow execution of commands immediately after paste. + // Ref: https://bugs.kde.org/show_bug.cgi?id=16179 + // Ref: https://github.com/KDE/konsole/commit/83d365f2ebfe2e659c1e857a2f5f247c556ab571 + if(appendReturn) { + text.append(QLatin1Char('\r')); + } + QKeyEvent e(QEvent::KeyPress, 0, Qt::NoModifier, text); emit keyPressedSignal(&e, true); // expose as a big fat keypress event