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) {}
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user