aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2016-11-27 22:47:27 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2016-11-27 22:47:27 +0100
commit8460f925248b99e94169bbfa9f2645de677f2e27 (patch)
treed891ae50b009c64797e84ed7299d7e2d2956dc66 /src
parent0fbbc0d99625e00e5a0389e28fc8dcd4160aeac2 (diff)
downloadsciteco-8460f925248b99e94169bbfa9f2645de677f2e27.tar.gz
fixed rubout of the first command after command line termination ($$)
* The $$ would leave the current state pointing to the "escape" state which was manually fixed up in macro return handling but not in command line return (ie. termination) handling. Therefore the initial state at the start of the command line after $$ was the "escape" state. The rubout-last-command immediate editing command would consequently end up in an infinite loop trying to reach the start state. * This has been fixed by setting the state before throwing Return(). Some additional paranoia assertions have been added to prevent this bug in the future.
Diffstat (limited to 'src')
-rw-r--r--src/cmdline.cpp2
-rw-r--r--src/parser.cpp10
2 files changed, 6 insertions, 6 deletions
diff --git a/src/cmdline.cpp b/src/cmdline.cpp
index 10e4a6b..f48714d 100644
--- a/src/cmdline.cpp
+++ b/src/cmdline.cpp
@@ -239,6 +239,8 @@ Cmdline::keypress(gchar key)
* The return "arguments" are currently
* ignored.
*/
+ g_assert(States::current == &States::start);
+
interface.popup_clear();
if (quit_requested)
diff --git a/src/parser.cpp b/src/parser.cpp
index de7184a..db68c18 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -212,11 +212,8 @@ Execute::macro(const gchar *macro, bool locals)
* end of macro, even though some checks
* are unnecessary here.
* macro_pc will still point to the return PC.
- * We are still in the "escape" state and must
- * reset it here, so it is not confused
- * with a trailing ^[ in macro.
*/
- States::current = &States::start;
+ g_assert(States::current == &States::start);
/*
* Discard all braces, except the current one.
@@ -252,8 +249,8 @@ Execute::macro(const gchar *macro, bool locals)
* Due to the deferred nature of ^[,
* it is valid to end in the "escape" state.
* FIXME: This could be avoided by signalling
- * the state the end of macro but State::refresh()
- * cannot be used :-(.
+ * the state the end of macro using a new
+ * virtual method.
*/
expressions.discard_args();
} else if (G_UNLIKELY(States::current != &States::start)) {
@@ -2152,6 +2149,7 @@ StateEscape::custom(gchar chr)
*/
if (chr == CTL_KEY_ESC) {
BEGIN_EXEC(&States::start);
+ States::current = &States::start;
expressions.eval();
throw Return(expressions.args());
}