tui: let users exit shell mode with escape key in addition to backspace at position 0

This commit is contained in:
Dax Raad 2025-10-02 19:06:28 -04:00
parent 2c16a77862
commit b42d1022a7

View file

@ -110,6 +110,7 @@ export function Prompt(props: PromptProps) {
command: input,
},
})
setStore("mode", "normal")
} else if (input.startsWith("/")) {
const [command, ...args] = input.split(" ")
sdk.session.command({
@ -230,10 +231,12 @@ export function Prompt(props: PromptProps) {
e.preventDefault()
return
}
if (e.name === "backspace" && input.cursorPosition === 0 && store.mode === "shell") {
setStore("mode", "normal")
e.preventDefault()
return
if (store.mode === "shell") {
if ((e.name === "backspace" && input.cursorPosition === 0) || e.name === "escape") {
setStore("mode", "normal")
e.preventDefault()
return
}
}
if (store.mode === "normal") autocomplete.onKeyDown(e)
if (!autocomplete.visible) {