diff options
-rw-r--r-- | src/core-commands.c | 12 | ||||
-rw-r--r-- | tests/testsuite.at | 5 |
2 files changed, 17 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; diff --git a/tests/testsuite.at b/tests/testsuite.at index dabab92..d770232 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -250,6 +250,11 @@ AT_CHECK([$SCITECO_CMDLINE "@I/ @:foo ${RUBOUT_WORD}/ Z-3\"N(0/0)'"], 0, ignore AT_FAIL_IF([$GREP "^Error:" stderr]) AT_CLEANUP +AT_SETUP([Command-line termination while editing replacement register]) +AT_CHECK([$SCITECO_CMDLINE '{$$}'], 0, ignore, stderr) +AT_FAIL_IF([! $GREP "^Error:" stderr]) +AT_CLEANUP + AT_BANNER([Standard library]) AT_SETUP([Command line opener]) |