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) {}
private isEscapeKey(char: string, key: readline.Key): boolean {
return key?.name === 'escape' || key?.sequence === '\x1b' || char === '\x1b';
}
private showHint(line: string): void {
if (!line.startsWith('/')) {
this.clearHint();
@@ -158,8 +162,8 @@ export class MinimalTui {
}
// Listen for line changes to show hints
this.keypressHandler = (_char: string, key: readline.Key) => {
if (key?.name === 'escape' && this.activePromptCancel) {
this.keypressHandler = (char: string, key: readline.Key) => {
if (this.activePromptCancel && this.isEscapeKey(char, key)) {
this.activePromptCancel();
return;
}