mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
fix(ui): resolve race condition in double-escape handler (#8913)
Co-authored-by: Megha Bansal <megha.igit@gmail.com>
This commit is contained in:
@@ -120,7 +120,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
|||||||
const isShellFocused = useShellFocusState();
|
const isShellFocused = useShellFocusState();
|
||||||
const { mainAreaWidth } = useUIState();
|
const { mainAreaWidth } = useUIState();
|
||||||
const [justNavigatedHistory, setJustNavigatedHistory] = useState(false);
|
const [justNavigatedHistory, setJustNavigatedHistory] = useState(false);
|
||||||
const [escPressCount, setEscPressCount] = useState(0);
|
const escPressCount = useRef(0);
|
||||||
const [showEscapePrompt, setShowEscapePrompt] = useState(false);
|
const [showEscapePrompt, setShowEscapePrompt] = useState(false);
|
||||||
const escapeTimerRef = useRef<NodeJS.Timeout | null>(null);
|
const escapeTimerRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
const [recentUnsafePasteTime, setRecentUnsafePasteTime] = useState<
|
const [recentUnsafePasteTime, setRecentUnsafePasteTime] = useState<
|
||||||
@@ -184,7 +184,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
|||||||
clearTimeout(escapeTimerRef.current);
|
clearTimeout(escapeTimerRef.current);
|
||||||
escapeTimerRef.current = null;
|
escapeTimerRef.current = null;
|
||||||
}
|
}
|
||||||
setEscPressCount(0);
|
escPressCount.current = 0;
|
||||||
setShowEscapePrompt(false);
|
setShowEscapePrompt(false);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -401,7 +401,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
|||||||
|
|
||||||
// Reset ESC count and hide prompt on any non-ESC key
|
// Reset ESC count and hide prompt on any non-ESC key
|
||||||
if (key.name !== 'escape') {
|
if (key.name !== 'escape') {
|
||||||
if (escPressCount > 0 || showEscapePrompt) {
|
if (escPressCount.current > 0 || showEscapePrompt) {
|
||||||
resetEscapeState();
|
resetEscapeState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -462,11 +462,11 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle double ESC for clearing input
|
// Handle double ESC for clearing input
|
||||||
if (escPressCount === 0) {
|
if (escPressCount.current === 0) {
|
||||||
if (buffer.text === '') {
|
if (buffer.text === '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setEscPressCount(1);
|
escPressCount.current = 1;
|
||||||
setShowEscapePrompt(true);
|
setShowEscapePrompt(true);
|
||||||
if (escapeTimerRef.current) {
|
if (escapeTimerRef.current) {
|
||||||
clearTimeout(escapeTimerRef.current);
|
clearTimeout(escapeTimerRef.current);
|
||||||
@@ -774,7 +774,6 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
|||||||
reverseSearchCompletion,
|
reverseSearchCompletion,
|
||||||
handleClipboardImage,
|
handleClipboardImage,
|
||||||
resetCompletionState,
|
resetCompletionState,
|
||||||
escPressCount,
|
|
||||||
showEscapePrompt,
|
showEscapePrompt,
|
||||||
resetEscapeState,
|
resetEscapeState,
|
||||||
vimHandleInput,
|
vimHandleInput,
|
||||||
|
|||||||
Reference in New Issue
Block a user