fix(tui): handle batched color scheme reports (#7550)

- fixes #7538
This commit is contained in:
Ramiz Wachtler 2026-08-03 15:24:34 +02:00 • committed by GitHub
parent c1019d9202
commit 0e633790c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View file

@ -26,7 +26,7 @@ function parseOscHexChannel(channel: string): number | undefined {
}
const OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN = /^\x1b\]11;([^\x07\x1b]*)(?:\x07|\x1b\\)$/i;
const COLOR_SCHEME_REPORT_PATTERN = /^\x1b\[\?997;(1|2)n$/;
const COLOR_SCHEME_REPORT_PATTERN = /^(?:\x1b\[\?997;(1|2)n)+$/;
export function isOsc11BackgroundColorResponse(data: string): boolean {
return OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN.test(data);

View file

@ -115,6 +115,8 @@ describe("parseTerminalColorSchemeReport", () => {
it("parses color scheme reports", () => {
assert.strictEqual(parseTerminalColorSchemeReport("\x1b[?997;1n"), "dark");
assert.strictEqual(parseTerminalColorSchemeReport("\x1b[?997;2n"), "light");
assert.strictEqual(parseTerminalColorSchemeReport("\x1b[?997;2n\x1b[?997;1n\x1b[?997;1n"), "dark");
assert.strictEqual(parseTerminalColorSchemeReport("\x1b[?997;1n\x1b[?997;2n\x1b[?997;2n"), "light");
assert.strictEqual(parseTerminalColorSchemeReport("\x1b[?997;3n"), undefined);
assert.strictEqual(parseTerminalColorSchemeReport("\x1b[?996n"), undefined);
assert.strictEqual(parseTerminalColorSchemeReport("x\x1b[?997;1n"), undefined);