aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cmdline.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2013-02-16 17:08:07 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2013-02-16 17:08:07 +0100
commit1f6254d363954c2a6b5b5d19390eb1ef9b19cf13 (patch)
tree1ba11eb674c85443abc554f0d6bef64fc602c401 /src/cmdline.cpp
parent8811c358f8c82aea515051b508b26fbfacb61e24 (diff)
downloadsciteco-1f6254d363954c2a6b5b5d19390eb1ef9b19cf13.tar.gz
fixed commandline replacements
ensure that undo tokens for first differing characters are actually associated with this character instead of the next. (resulted in strange behaviour on rubout and subsequent replacements)
Diffstat (limited to 'src/cmdline.cpp')
-rw-r--r--src/cmdline.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/cmdline.cpp b/src/cmdline.cpp
index e73c148..f374efc 100644
--- a/src/cmdline.cpp
+++ b/src/cmdline.cpp
@@ -86,7 +86,7 @@ cmdline_keypress(gchar key)
cmdline_pos = cmdline ? strlen(cmdline)+1 : 1;
String::append(cmdline, insert);
- while (cmdline_pos <= (gint)strlen(cmdline)) {
+ while (cmdline[cmdline_pos-1]) {
try {
Execute::step(cmdline, cmdline_pos);
} catch (ReplaceCmdline &r) {
@@ -96,6 +96,7 @@ cmdline_keypress(gchar key)
cmdline = r.new_cmdline;
cmdline_pos = repl_pos = r.pos;
macro_pc = r.pos-1;
+ continue;
} catch (...) {
if (old_cmdline) {
undo.pop(repl_pos);
@@ -104,22 +105,22 @@ cmdline_keypress(gchar key)
cmdline = old_cmdline;
cmdline[strlen(cmdline)-1] = '\0';
old_cmdline = NULL;
- cmdline_pos = repl_pos-1;
+ cmdline_pos = repl_pos;
macro_pc = repl_pos-1;
- } else {
- /*
- * Undo tokens may have been emitted
- * (or had to be) before the exception
- * is thrown. They must be executed so
- * as if the character had never been
- * inserted.
- */
- undo.pop(cmdline_pos);
- cmdline[cmdline_pos-1] = '\0';
- /* program counter could be messed up */
- macro_pc = cmdline_pos - 1;
- break;
+ continue;
}
+ /*
+ * Undo tokens may have been emitted
+ * (or had to be) before the exception
+ * is thrown. They must be executed so
+ * as if the character had never been
+ * inserted.
+ */
+ undo.pop(cmdline_pos);
+ cmdline[cmdline_pos-1] = '\0';
+ /* program counter could be messed up */
+ macro_pc = cmdline_pos - 1;
+ break;
}
cmdline_pos++;