mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-07-15 21:03:47 +00:00
Fix fish prompt OSC highlighting (#998)
This commit is contained in:
@@ -76,6 +76,16 @@ describe("highlightTerminalOutput", () => {
|
|||||||
expect(highlightTerminalOutput(chunk)).toBe(chunk);
|
expect(highlightTerminalOutput(chunk)).toBe(chunk);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("skips OSC current-directory sequences used by fish prompts", () => {
|
||||||
|
const chunk = `${ESC}]7;file://server/home/user/docker/sonarr\x07user@server ~/docker/sonarr> `;
|
||||||
|
expect(highlightTerminalOutput(chunk)).toBe(chunk);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("skips OSC title sequences", () => {
|
||||||
|
const chunk = `${ESC}]0;user@server:/var/log\x07ERROR after title`;
|
||||||
|
expect(highlightTerminalOutput(chunk)).toBe(chunk);
|
||||||
|
});
|
||||||
|
|
||||||
it("highlights text that already has ANSI codes", () => {
|
it("highlights text that already has ANSI codes", () => {
|
||||||
let heavy = "";
|
let heavy = "";
|
||||||
for (let i = 0; i < 12; i++) heavy += `${ESC}[32mgreen${ESC}[0m `;
|
for (let i = 0; i < 12; i++) heavy += `${ESC}[32mgreen${ESC}[0m `;
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ const MAX_LINE_LENGTH = 2000;
|
|||||||
// extra SGR bytes into a full-screen redraw and corrupt xterm's cursor state.
|
// extra SGR bytes into a full-screen redraw and corrupt xterm's cursor state.
|
||||||
const TUI_SEQUENCE = /\x1b\[(?:[\d;]*[ABCDEFGHJKST]|\?[\d;]*[hl])/;
|
const TUI_SEQUENCE = /\x1b\[(?:[\d;]*[ABCDEFGHJKST]|\?[\d;]*[hl])/;
|
||||||
const TUI_FRAME_SEQUENCE = /[\u2500-\u257f]|\x1b[()][0B]|\x1b\[[0-9;]*[~`]/;
|
const TUI_FRAME_SEQUENCE = /[\u2500-\u257f]|\x1b[()][0B]|\x1b\[[0-9;]*[~`]/;
|
||||||
|
const CONTROL_STRING_SEQUENCE = /\x1b[\]P^_]/;
|
||||||
|
|
||||||
// A bare \r (not immediately followed by \n) means the terminal is overwriting
|
// A bare \r (not immediately followed by \n) means the terminal is overwriting
|
||||||
// the current line (shell prompts, progress bars). Highlighting mid-rewrite
|
// the current line (shell prompts, progress bars). Highlighting mid-rewrite
|
||||||
@@ -400,6 +401,7 @@ export function highlightTerminalOutput(
|
|||||||
|
|
||||||
if (TUI_SEQUENCE.test(text)) return text;
|
if (TUI_SEQUENCE.test(text)) return text;
|
||||||
if (TUI_FRAME_SEQUENCE.test(text)) return text;
|
if (TUI_FRAME_SEQUENCE.test(text)) return text;
|
||||||
|
if (CONTROL_STRING_SEQUENCE.test(text)) return text;
|
||||||
if (MID_LINE_CR.test(text)) return text;
|
if (MID_LINE_CR.test(text)) return text;
|
||||||
|
|
||||||
const activePatterns = buildActivePatterns(options);
|
const activePatterns = buildActivePatterns(options);
|
||||||
|
|||||||
Reference in New Issue
Block a user