]> git.lyx.org Git - features.git/commitdiff
Change backspace behavior in align type equations
authorEnrico Forestieri <forenr@lyx.org>
Sat, 30 Jan 2021 23:51:15 +0000 (00:51 +0100)
committerEnrico Forestieri <forenr@lyx.org>
Sat, 30 Jan 2021 23:51:15 +0000 (00:51 +0100)
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

src/Cursor.cpp

index 074047f4901f634a21ff0ff70d9b25787ac17883..fae9d85c3f3c98bf743fc89592aa3e52b8fdf1eb 100644 (file)
@@ -1594,9 +1594,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;
                }