aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2013-07-05 20:41:55 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2013-07-05 20:41:55 +0200
commitf510c10ff3c0222621582d700e5b02e6d97ea22d (patch)
tree49979c5c51c58384b7db91dbae4543f940e6d899
parent46599080236debda27263ea05d9293069e9ddb4f (diff)
downloadsciteco-f510c10ff3c0222621582d700e5b02e6d97ea22d.tar.gz
only allow command-line replacements when actually editing the replacement register
I felt the urge to implement that after accidentally rubbing out my entire commandline (the work of an hour) just by pressing "}"...
-rw-r--r--src/parser.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 66880e3..4572f02 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -908,6 +908,10 @@ StateStart::custom(gchar chr) throw (Error, ReplaceCmdline)
* up to the first changed character and inserts
* all characters following from the updated command
* line into the command stream.
+ * To prevent the undesired rubout of the entire
+ * command-line, the replacement command ("}") is only
+ * allowed when the replacement register currently edited
+ * since it will otherwise be usually empty.
*
* .B Note:
* - Command line editing only works on command lines,
@@ -964,6 +968,9 @@ StateStart::custom(gchar chr) throw (Error, ReplaceCmdline)
if (!undo.enabled)
throw Error("Command-line editing only possible in "
"interactive mode");
+ if (QRegisters::current != QRegisters::globals["\x1B"])
+ throw Error("Command-line replacement only allowed when "
+ "editing the replacement register");
/* replace cmdline in the outer macro environment */
throw ReplaceCmdline();