diff --git a/src/tty_interface.c b/src/tty_interface.c index 6e09852..3dcfec6 100644 --- a/src/tty_interface.c +++ b/src/tty_interface.c @@ -132,6 +132,13 @@ static void action_emit(tty_interface_t *state) { state->exit = EXIT_SUCCESS; } +static void action_exit(tty_interface_t *state) { + clear(state); + tty_close(state->tty); + + state->exit = EXIT_FAILURE; +} + static void action_del_char(tty_interface_t *state) { if (*state->search) { size_t length = strlen(state->search); @@ -141,6 +148,8 @@ static void action_del_char(tty_interface_t *state) { state->cursor--; memmove(&state->search[state->cursor], &state->search[state->cursor + 1], length - state->cursor); + } else { + action_exit(state); } } @@ -216,13 +225,6 @@ static void action_autocomplete(tty_interface_t *state) { } } -static void action_exit(tty_interface_t *state) { - clear(state); - tty_close(state->tty); - - state->exit = EXIT_FAILURE; -} - static void append_search(tty_interface_t *state, char ch) { char *search = state->search; size_t search_size = strlen(search);