[LyX/2.3.x] Change backspace behavior in align type equations

Enrico Forestieri forenr at lyx.org
Mon Feb 1 15:33:57 UTC 2021


commit 706db1ff2ed92631eaf6078b69b14cc3e0b8ebbe
Author: Enrico Forestieri <forenr at lyx.org>
Date:   Sun Jan 31 00:51:15 2021 +0100

    Change backspace behavior in align type equations
    
    When hitting backspace in the first position of a cell in mathed,
    if the cell is part of an array, the whole array is dissolved
    and the sole cell content pasted in the containing environment.
    
    But if the cell is part of an eqnarray or align math hull type, the
    cursor is simply (and unexpectedly) taken out of the whole equation,
    which is left unchanged.
    
    This patch makes backspace equivalent to the cursor left key in those
    cases, while leaving the behavior unchanged in all other ones.
    
    Fixes #11678
    
    (cherry picked from commit c79ec4114e419ae8f4711c4c07ab0df19dafaaa3)
---
 src/Cursor.cpp |   17 ++++++++++++++---
 status.23x     |    4 +++-
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index dc38147..0963da6 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -1347,9 +1347,20 @@ bool Cursor::backspace(bool const force)
 			// [|], can not delete from inside
 			return false;
 		} else {
-			if (inMathed())
-				pullArg();
-			else
+			if (inMathed()) {
+				switch (inset().asInsetMath()->getType()) {
+				case hullEqnArray:
+				case hullAlign:
+				case hullFlAlign: {
+					FuncRequest cmd(LFUN_CHAR_BACKWARD);
+					this->dispatch(cmd);
+					break;
+				}
+				default:
+					pullArg();
+					break;
+				}
+			} else
 				popBackward();
 			return true;
 		}
diff --git a/status.23x b/status.23x
index 6e43727..89d4790 100644
--- a/status.23x
+++ b/status.23x
@@ -27,7 +27,9 @@ What's new
 
 * USER INTERFACE
 
-
+- Backspace at the very start of a cell part of eqnarray or align environments
+  does not move the cursor out of the whole equation anymore and is now
+  equivalent to hitting the left arrow key (bug 11678).
 
 
 * DOCUMENTATION AND LOCALIZATION


More information about the lyx-cvs mailing list