From d217d6b9ba9012bc374ac0d44d48422b7b13b755 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Sun, 31 Dec 2023 06:49:08 +1000 Subject: [PATCH] con: allow alias loops involving wait to be broken, eg with unalias or quit Signed-off-by: bones_was_here --- cmd.c | 4 +++- keys.c | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd.c b/cmd.c index 0343dd10..df218d9e 100644 --- a/cmd.c +++ b/cmd.c @@ -425,8 +425,10 @@ static void Cbuf_Frame_Input(void) { char *line; + // bones_was_here: prepending allows a loop such as `alias foo "bar; wait; foo"; foo` + // to be broken with an alias or unalias command while ((line = Sys_ConsoleInput())) - Cbuf_AddText(cmd_local, line); + Cbuf_InsertText(cmd_local, line); } void Cbuf_Frame(cmd_buf_t *cbuf) diff --git a/keys.c b/keys.c index 739510ec..fd0a24b2 100644 --- a/keys.c +++ b/keys.c @@ -1098,8 +1098,7 @@ static int Key_Convert_NumPadKey(int key) return key; } -static void -Key_Console(cmd_state_t *cmd, int key, int unicode) +static void Key_Console(cmd_state_t *cmd, int key, int unicode) { int linepos; @@ -1121,8 +1120,9 @@ Key_Console(cmd_state_t *cmd, int key, int unicode) if ((key == K_ENTER || key == K_KP_ENTER) && KM_NONE) { - Cbuf_AddText (cmd, key_line+1); // skip the ] - Cbuf_AddText (cmd, "\n"); + // bones_was_here: prepending allows a loop such as `alias foo "bar; wait; foo"; foo` + // to be broken with an alias or unalias command + Cbuf_InsertText(cmd, key_line+1); // skip the ] Key_History_Push(); key_linepos = Key_ClearEditLine(true); // force an update, because the command may take some time -- 2.39.2