Pārlūkot izejas kodu

BUG: ctkConsole: Backspace working in every case in the PythonConsole

Prior to this commit, doing a selection followed by backspace was NOT
working in the following cases:
* using the mouse
* typing "Shift+Home"
* typing "Shift+[multiple 'Left' until the beginning of the command]

Co-authored-by: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Mayeul Chassagnard 8 gadi atpakaļ
vecāks
revīzija
abf47613af
1 mainītis faili ar 5 papildinājumiem un 1 dzēšanām
  1. 5 1
      Libs/Widgets/ctkConsole.cpp

+ 5 - 1
Libs/Widgets/ctkConsole.cpp

@@ -460,7 +460,11 @@ void ctkConsolePrivate::keyPressEvent(QKeyEvent* e)
   if (e->key() == Qt::Key_Backspace && !(e->modifiers() & ~Qt::ShiftModifier))
     {
     e->accept();
-    if(text_cursor.position() > this->InteractivePosition)
+    // Can delete with backspace only if the cursor is after the InteractivePosition.
+    // There is an exception if something is selected, because it will erase the text selected instead.
+    if (text_cursor.position() > this->InteractivePosition
+        || (text_cursor.position() >= this->InteractivePosition
+             && selection))
       {
       this->Superclass::keyPressEvent(e);
       this->updateCommandBuffer();