changeset 29320:843b1f794544

Handle tabs in pasted code (bug #59916). Replace tabs with spaces before passing pasted code to Octave interpreter. This avoids odd auto-complete actions from Readline. * TerminalView.cpp (emitSelection): Check "text" variable for tabs with QString function contains(). If found, emit a warning and replace with 4 spaces using QString function replace(). * QWinTerminalImpl.cpp (pasteClipboard): Check "text" variable for tabs with QString function contains(). If found, emit a warning and replace with 4 spaces using QString function replace().
author Rik <rik@octave.org>
date Sun, 24 Jan 2021 15:42:27 -0800
parents 7bb6a7cbb65e
children 78c660a8ba84
files libgui/qterminal/libqterminal/unix/TerminalView.cpp libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/qterminal/libqterminal/unix/TerminalView.cpp	Sat Jan 23 17:28:14 2021 +0100
+++ b/libgui/qterminal/libqterminal/unix/TerminalView.cpp	Sun Jan 24 15:42:27 2021 -0800
@@ -2208,6 +2208,11 @@
   if ( ! text.isEmpty() )
     {
       text.replace("\n", "\r");
+      if (text.contains ("\t"))
+        {
+          qWarning ("Tabs replaced with spaces in pasted text before processing");
+          text.replace ("\t", "    ");
+        }
       QKeyEvent e(QEvent::KeyPress, 0, Qt::NoModifier, text);
       emit keyPressedSignal(&e); // expose as a big fat keypress event
 
--- a/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp	Sat Jan 23 17:28:14 2021 +0100
+++ b/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp	Sun Jan 24 15:42:27 2021 -0800
@@ -1814,7 +1814,15 @@
   QString text = QApplication::clipboard()->text (QClipboard::Clipboard);
 
   if (! text.isEmpty ())
+    {
+      if (text.contains ("\t"))
+        {
+          qWarning ("Tabs replaced with spaces in pasted text before processing");
+          text.replace ("\t", "    ");
+        }
+
     sendText (text);
+    }
 }
 
 //////////////////////////////////////////////////////////////////////////////