changeset 31086:d5696a4efa84

exp cmd widget: fix preventing prompt deletion * command-widget.cc (cursor_position_changed): store current position in correct variable, add last char of prompt if deleted this by backspace
author Torsten Lilge <ttl-octave@mailbox.org>
date Fri, 10 Jun 2022 18:02:21 +0200
parents 037c1e768b56
children 9c0099048264
files libgui/src/command-widget.cc
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/command-widget.cc	Thu Jun 09 09:00:17 2022 -0400
+++ b/libgui/src/command-widget.cc	Fri Jun 10 18:02:21 2022 +0200
@@ -249,14 +249,17 @@
   // Cursor position changed: Are we in the command line or not?
   void console::cursor_position_changed (int line, int col)
   {
-    m_command_position = positionFromLineIndex (line, col);
+    m_cursor_position = positionFromLineIndex (line, col);
     if (m_cursor_position < m_command_position)
       {
         // We are in the read only area
         if (m_text_changed && (m_cursor_position == m_command_position - 1))
-          undo ();  // And here we have tried to remove the prompt by Backspace
-        else
-          setReadOnly (true);
+          {
+            setReadOnly (false);
+            insert (m_command_widget->prompt ().right (1)); // And here we have tried to remove the prompt by Backspace
+            setCursorPosition (line+1, col);
+          }
+        setReadOnly (true);
       }
     else
       setReadOnly (false);  // Writable area