Merge pull request #20 from ringcrl/main

fix(PromptInput): prevent premature mode change when deleting in bash mode
This commit is contained in:
Xinlu Lai 2025-08-13 00:58:45 +08:00 committed by GitHub
commit 40070119bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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: