Infer modifyOtherKeys support (#16270)

This commit is contained in:
Tommaso Sciortino
2026-01-09 13:10:15 -08:00
committed by GitHub
parent c7d17dda49
commit ea7393f7fd
4 changed files with 43 additions and 31 deletions
@@ -43,14 +43,13 @@ export class TerminalCapabilityManager {
// eslint-disable-next-line no-control-regex
private static readonly MODIFY_OTHER_KEYS_REGEX = /\x1b\[>4;(\d+)m/;
private detectionComplete = false;
private terminalBackgroundColor: TerminalBackgroundColor;
private kittySupported = false;
private kittyEnabled = false;
private detectionComplete = false;
private terminalName: string | undefined;
private modifyOtherKeysSupported = false;
private modifyOtherKeysEnabled = false;
private bracketedPasteEnabled = false;
private modifyOtherKeysSupported?: boolean;
private deviceAttributesSupported = false;
private constructor() {}
@@ -187,6 +186,7 @@ export class TerminalCapabilityManager {
);
if (match) {
deviceAttributesReceived = true;
this.deviceAttributesSupported = true;
cleanup();
}
}
@@ -215,13 +215,17 @@ export class TerminalCapabilityManager {
if (this.kittySupported) {
enableKittyKeyboardProtocol();
this.kittyEnabled = true;
} else if (this.modifyOtherKeysSupported) {
} else if (
this.modifyOtherKeysSupported === true ||
// If device attributes were received it's safe to try enabling
// anyways, since it will be ignored if unsupported
(this.modifyOtherKeysSupported === undefined &&
this.deviceAttributesSupported)
) {
enableModifyOtherKeys();
this.modifyOtherKeysEnabled = true;
}
// Always enable bracketed paste since it'll be ignored if unsupported.
enableBracketedPasteMode();
this.bracketedPasteEnabled = true;
} catch (e) {
debugLogger.warn('Failed to enable keyboard protocols:', e);
}
@@ -239,14 +243,6 @@ export class TerminalCapabilityManager {
return this.kittyEnabled;
}
isBracketedPasteEnabled(): boolean {
return this.bracketedPasteEnabled;
}
isModifyOtherKeysEnabled(): boolean {
return this.modifyOtherKeysEnabled;
}
private parseColor(rHex: string, gHex: string, bHex: string): string {
const parseComponent = (hex: string) => {
const val = parseInt(hex, 16);