aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-05-03 14:18:15 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-05-03 14:18:15 +0300
commit32bb5f440b0a029c0cff0b6840bc19f3abb20ddd (patch)
treee6a4d942cf5c5b05826722f84ac51673037034b1 /src
parent850000492cd43e40109b3a11c8613b5fff577755 (diff)
downloadsciteco-32bb5f440b0a029c0cff0b6840bc19f3abb20ddd.tar.gz
disallow command-line termination ($$) while editing the command-line replacement register (after `{`)
I found that terminating the command-line while editing the replacement register, leaves you in a hard-to-recover state. You can/should no longer call `}`, so you would have to go back to the last buffer (Q*U*). Instead, this is now checked against and a test case has also been added.
Diffstat (limited to 'src')
-rw-r--r--src/core-commands.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core-commands.c b/src/core-commands.c
index dbf86bd..141ce0a 100644
--- a/src/core-commands.c
+++ b/src/core-commands.c
@@ -1698,6 +1698,18 @@ teco_state_escape_input(teco_machine_main_t *ctx, gunichar chr, GError **error)
if (ctx->flags.mode > TECO_MODE_NORMAL)
return &teco_state_start;
+ /*
+ * This check is not crucial, but it would be impossible to apply the new
+ * command line with `}` after command-line termination.
+ */
+ if (G_UNLIKELY(ctx == &teco_cmdline.machine &&
+ teco_qreg_current && !teco_string_cmp(&teco_qreg_current->head.name, "\e", 1))) {
+ g_set_error_literal(error, TECO_ERROR, TECO_ERROR_FAILED,
+ "Not allowed to terminate command-line while "
+ "editing command-line replacement register");
+ return NULL;
+ }
+
ctx->parent.current = &teco_state_start;
if (!teco_expressions_eval(FALSE, error))
return NULL;