Skip to content

Commit e9751d2

Browse files
committed
unix: Properly cancel REPL input when Ctrl-C is pressed.
1 parent 401af50 commit e9751d2

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

unix/main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,11 @@ STATIC int do_repl(void) {
176176
int ret = readline(&line, ">>> ");
177177
mp_parse_input_kind_t parse_input_kind = MP_PARSE_SINGLE_INPUT;
178178

179-
if (ret == CHAR_CTRL_D) {
179+
if (ret == CHAR_CTRL_C) {
180+
// cancel input
181+
mp_hal_stdout_tx_str("\r\n");
182+
goto input_restart;
183+
} else if (ret == CHAR_CTRL_D) {
180184
// EOF
181185
printf("\n");
182186
mp_hal_stdio_mode_orig();

0 commit comments

Comments
 (0)