Parcourir la source

BUG: ctkConsole: Fix delete/BackSpace when cursor = commandEnd/InteractivePosition

* was deleting wrongly if
   cursor.pos = commandEnd() and
   there was a selection in the message_output_area
* was deleting wrongly if
   cursor.pos = InteractivePosition and
   there was a selection in the message_output_area

Co-authored-by: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Mayeul Chassagnard il y a 8 ans
Parent
commit
96027a4bca
1 fichiers modifiés avec 6 ajouts et 4 suppressions
  1. 6 4
      Libs/Widgets/ctkConsole.cpp

+ 6 - 4
Libs/Widgets/ctkConsole.cpp

@@ -444,10 +444,11 @@ void ctkConsolePrivate::keyPressEvent(QKeyEvent* e)
     {
     e->accept();
     // Can delete only if we are not at the end of the command line.
-    // There is an exception if something is selected because it will erase the text selected instead.
+    // There is an exception if something (in the interactive area only) is selected,
+    // because it will erase the text selected instead.
     if (text_cursor.position() < this->commandEnd()
         || (text_cursor.position() <= this->commandEnd()
-             && selection))
+             && selection && !message_output_area && !history_area))
       {
       this->Superclass::keyPressEvent(e);
       this->updateCommandBuffer();
@@ -461,10 +462,11 @@ void ctkConsolePrivate::keyPressEvent(QKeyEvent* e)
     {
     e->accept();
     // 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.
+    // There is an exception if something (in the interactive area only) is selected,
+    // because it will erase the text selected instead.
     if (text_cursor.position() > this->InteractivePosition
         || (text_cursor.position() >= this->InteractivePosition
-             && selection))
+             && selection  && !message_output_area && !history_area))
       {
       this->Superclass::keyPressEvent(e);
       this->updateCommandBuffer();