fix(tui): detect escape key variants for prompt cancellation
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user