Add Esc-Esc to clear prompt when it's not empty (#17131)

This commit is contained in:
Adib234
2026-01-20 19:32:26 -05:00
committed by GitHub
parent 3b626e7c61
commit e1fd5be429
7 changed files with 82 additions and 12 deletions

View File

@@ -138,7 +138,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
const kittyProtocol = useKittyKeyboardProtocol();
const isShellFocused = useShellFocusState();
const { setEmbeddedShellFocused } = useUIActions();
const { mainAreaWidth, activePtyId } = useUIState();
const { mainAreaWidth, activePtyId, history } = useUIState();
const [justNavigatedHistory, setJustNavigatedHistory] = useState(false);
const escPressCount = useRef(0);
const [showEscapePrompt, setShowEscapePrompt] = useState(false);
@@ -495,7 +495,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
return;
}
// Handle double ESC for rewind
// Handle double ESC
if (escPressCount.current === 0) {
escPressCount.current = 1;
setShowEscapePrompt(true);
@@ -506,9 +506,16 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
resetEscapeState();
}, 500);
} else {
// Second ESC triggers rewind
// Second ESC
resetEscapeState();
onSubmit('/rewind');
if (buffer.text.length > 0) {
buffer.setText('');
resetCompletionState();
} else {
if (history.length > 0) {
onSubmit('/rewind');
}
}
}
return;
}
@@ -880,6 +887,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
onSubmit,
activePtyId,
setEmbeddedShellFocused,
history,
],
);