fix(tui): provide the JetBrains terminal capabilities (#5037)
This commit is contained in:
committed by
GitHub
parent
b62776e4a2
commit
4bbe2959bd
@@ -41,6 +41,7 @@ export function setCellDimensions(dims: CellDimensions): void {
|
|||||||
|
|
||||||
export function detectCapabilities(): TerminalCapabilities {
|
export function detectCapabilities(): TerminalCapabilities {
|
||||||
const termProgram = process.env.TERM_PROGRAM?.toLowerCase() || "";
|
const termProgram = process.env.TERM_PROGRAM?.toLowerCase() || "";
|
||||||
|
const terminalEmulator = process.env.TERMINAL_EMULATOR?.toLowerCase() || "";
|
||||||
const term = process.env.TERM?.toLowerCase() || "";
|
const term = process.env.TERM?.toLowerCase() || "";
|
||||||
const colorTerm = process.env.COLORTERM?.toLowerCase() || "";
|
const colorTerm = process.env.COLORTERM?.toLowerCase() || "";
|
||||||
const hasTrueColorHint = colorTerm === "truecolor" || colorTerm === "24bit";
|
const hasTrueColorHint = colorTerm === "truecolor" || colorTerm === "24bit";
|
||||||
@@ -82,6 +83,10 @@ export function detectCapabilities(): TerminalCapabilities {
|
|||||||
return { images: null, trueColor: true, hyperlinks: true };
|
return { images: null, trueColor: true, hyperlinks: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (terminalEmulator === "jetbrains-jediterm") {
|
||||||
|
return { images: null, trueColor: true, hyperlinks: false };
|
||||||
|
}
|
||||||
|
|
||||||
// Unknown terminal: be conservative. OSC 8 is rendered invisibly as "just
|
// Unknown terminal: be conservative. OSC 8 is rendered invisibly as "just
|
||||||
// text" on terminals that swallow it, which means the URL disappears from
|
// text" on terminals that swallow it, which means the URL disappears from
|
||||||
// the rendered output. Default to the legacy `text (url)` behavior unless we
|
// the rendered output. Default to the legacy `text (url)` behavior unless we
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
const ENV_KEYS = [
|
const ENV_KEYS = [
|
||||||
"TERM",
|
"TERM",
|
||||||
"TERM_PROGRAM",
|
"TERM_PROGRAM",
|
||||||
|
"TERMINAL_EMULATOR",
|
||||||
"COLORTERM",
|
"COLORTERM",
|
||||||
"TMUX",
|
"TMUX",
|
||||||
"KITTY_WINDOW_ID",
|
"KITTY_WINDOW_ID",
|
||||||
@@ -282,6 +283,15 @@ describe("detectCapabilities", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("enables truecolor without hyperlinks for JetBrains terminal", () => {
|
||||||
|
withEnv({ TERMINAL_EMULATOR: "JetBrains-JediTerm", TERM: "xterm-256color" }, () => {
|
||||||
|
const caps = detectCapabilities();
|
||||||
|
assert.strictEqual(caps.trueColor, true);
|
||||||
|
assert.strictEqual(caps.hyperlinks, false);
|
||||||
|
assert.strictEqual(caps.images, null);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("does not inherit Windows Terminal truecolor through tmux", () => {
|
it("does not inherit Windows Terminal truecolor through tmux", () => {
|
||||||
withEnv({ WT_SESSION: "session", TMUX: "/tmp/tmux-1000/default,1234,0", TERM: "tmux-256color" }, () => {
|
withEnv({ WT_SESSION: "session", TMUX: "/tmp/tmux-1000/default,1234,0", TERM: "tmux-256color" }, () => {
|
||||||
const caps = detectCapabilities();
|
const caps = detectCapabilities();
|
||||||
|
|||||||
Reference in New Issue
Block a user