]> git.lyx.org Git - features.git/commitdiff
Kill macro mode when using LFUN_ESCAPE
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 20 Feb 2018 11:09:10 +0000 (12:09 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 21 Feb 2018 10:24:32 +0000 (11:24 +0100)
Add a `cancel' boolean to macroModeClose() that just removes all trace
of what has been entered instead of finalizing it.

When entering a macro in mathed, let LFUN_ESCAPE invoke
macroModeClose(true). The new semantics of LFUN_ESCAPE in mathed is
thus to abort the input of a macro name.

Fixes bug #9251.

(cherry picked from commit 9296344b9a26191a2092d175a51e357ecc35145d)

src/Cursor.cpp
src/Cursor.h
src/mathed/InsetMathNest.cpp
status.22x

index 0b7798485b0083e29a9b4b2e3f1ac5e6359c34db..7b745a23873e4d2a156aeaca2591c62fa77b8cd5 100644 (file)
@@ -1528,7 +1528,7 @@ bool Cursor::down()
 }
 
 
-bool Cursor::macroModeClose()
+bool Cursor::macroModeClose(bool cancel)
 {
        if (!inMacroMode())
                return false;
@@ -1541,7 +1541,7 @@ bool Cursor::macroModeClose()
        cell().erase(pos());
 
        // do nothing if the macro name is empty
-       if (s == "\\")
+       if (s == "\\" || cancel)
                return false;
 
        // trigger updates of macros, at least, if no full
index a0f5ec14bf14f4ac434163f7690f6e264bbe17b6..a2b065b4c78a89f699342f63707a7635942ba843 100644 (file)
@@ -488,9 +488,9 @@ public:
        void setScreenPos(int x, int y);
        /// current offset in the top cell
 
-       /// interpret name a name of a macro. Returns true if
-       /// something got inserted.
-       bool macroModeClose();
+       /// interpret name of a macro or ditch it if \c cancel is true.
+       /// Returns true if something got inserted.
+       bool macroModeClose(bool cancel = false);
        /// are we currently typing the name of a macro?
        bool inMacroMode() const;
        /// get access to the macro we are currently typing
index fc7690dc7a73364c11ba09a1c077aace0c3c7e48..c83c7229688f5ba3d8a98e9d9b75fc6589a441b1 100644 (file)
@@ -870,8 +870,12 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                if (cur.selection())
                        cur.clearSelection();
                else  {
-                       cmd = FuncRequest(LFUN_FINISHED_FORWARD);
-                       cur.undispatched();
+                       if (cur.inMacroMode())
+                               cur.macroModeClose(true);
+                       else {
+                               cmd = FuncRequest(LFUN_FINISHED_FORWARD);
+                               cur.undispatched();
+                       }
                }
                break;
 
index e43dd45afbfbebebc7a56a836334201e931c51fd..a91ad6bb584544a8990986862b8e46012c348de2 100644 (file)
@@ -152,6 +152,9 @@ What's new
 
 - Fix untranslated GUI strings on View/Update toolbar button menu (bug 11040).
 
+- When entering a math macro name, Escape properly cancels the
+  operation (bug 9251).
+
 
 * INTERNALS