From d2be2f945aa9fd1682eb7d4cd2706a1f974e3e67 Mon Sep 17 00:00:00 2001 From: ringcrl Date: Tue, 12 Aug 2025 19:58:41 +0800 Subject: [PATCH] feat(PromptInput): add bash mode specific handling for backspace/delete refactor(PromptInput): rename input parameter to inputChar for clarity fix(PromptInput): prevent premature mode change when deleting in bash mode --- src/components/PromptInput.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/PromptInput.tsx b/src/components/PromptInput.tsx index 39fc47d..b246be2 100644 --- a/src/components/PromptInput.tsx +++ b/src/components/PromptInput.tsx @@ -446,8 +446,18 @@ function PromptInput({ setPastedText(text) } - useInput((input, key) => { - if (input === '' && (key.escape || key.backspace || key.delete)) { + useInput((inputChar, key) => { + // For bash mode, only exit when deleting the last character (which would be the '!' character) + if (mode === 'bash' && (key.backspace || key.delete)) { + // Check the current input state, not the inputChar parameter + // If current input is empty, we're about to delete the '!' character, so exit bash mode + if (input === '') { + onModeChange('prompt') + } + return + } + // For other modes, keep the original behavior + if (inputChar === '' && (key.escape || key.backspace || key.delete)) { onModeChange('prompt') } // esc is a little overloaded: