fix(tui): detect escape key variants for prompt cancellation

This commit is contained in:
William Valentin
2026-02-16 11:34:05 -08:00
parent c34ae9b75b
commit 205203a458
+6 -2
View File
@@ -80,6 +80,10 @@ export class MinimalTui {
constructor(private config: MinimalTuiConfig) {} constructor(private config: MinimalTuiConfig) {}
private isEscapeKey(char: string, key: readline.Key): boolean {
return key?.name === 'escape' || key?.sequence === '\x1b' || char === '\x1b';
}
private showHint(line: string): void { private showHint(line: string): void {
if (!line.startsWith('/')) { if (!line.startsWith('/')) {
this.clearHint(); this.clearHint();
@@ -158,8 +162,8 @@ export class MinimalTui {
} }
// Listen for line changes to show hints // Listen for line changes to show hints
this.keypressHandler = (_char: string, key: readline.Key) => { this.keypressHandler = (char: string, key: readline.Key) => {
if (key?.name === 'escape' && this.activePromptCancel) { if (this.activePromptCancel && this.isEscapeKey(char, key)) {
this.activePromptCancel(); this.activePromptCancel();
return; return;
} }