From 32bb5f440b0a029c0cff0b6840bc19f3abb20ddd Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 3 May 2025 14:18:15 +0300 Subject: 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. --- src/core-commands.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') 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; -- cgit v1.2.3