]> 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)
committerRichard Heck <rgheck@lyx.org>
Sat, 17 Mar 2018 19:44:05 +0000 (15:44 -0400)
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.23x

index 2e8060509de0dbfd40af8033640bfc971463314e..984eb09ae523a77de6951a9ac9f5b90a1f7073f2 100644 (file)
@@ -1413,7 +1413,7 @@ bool Cursor::down()
 }
 
 
-bool Cursor::macroModeClose()
+bool Cursor::macroModeClose(bool cancel)
 {
        if (!inMacroMode())
                return false;
@@ -1426,7 +1426,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 8a8c71996d52a959b4cae283a5bf8014cd9a814d..1e66778e99c5e69011ce1df5b4674a467c0113ae 100644 (file)
@@ -502,9 +502,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 f9c8813a01249ec1328b5e5b7428940f0fe25aae..af50a7ec3cc6974cf7e5a088b716ca81e7432034 100644 (file)
@@ -836,8 +836,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 74dc00f2781c673c83716cce2e625478a007f1f9..42bc947d4d474cd7e8b0f8cbe4a0cb8720816cf6 100644 (file)
@@ -57,6 +57,9 @@ What's new
 
 - Fix ChkTeX on Windows (requires ChkTeX 1.7.7 at least) (bug 9989).
 
+- When entering a math macro name, Escape properly cancels the
+  operation (bug 9251).
+
 
 * INTERNALS