Skip to content

Commit aa62e83

Browse files
authored
fix(editor): improve selection contrast on active lines (#2852)
1 parent 12e14ba commit aa62e83

6 files changed

Lines changed: 22 additions & 5 deletions

File tree

src/cm/themes/catppuccin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ function createConfig(name, caption, palette) {
113113
cursor: palette.rosewater,
114114
dropdownBackground: palette.mantle,
115115
dropdownBorder: palette.overlay0,
116-
activeLine: palette.surface0,
116+
// Keep this translucent: CodeMirror draws selections behind line backgrounds.
117+
activeLine: `${palette.surface0}40`,
117118
lineNumber: palette.subtext0,
118119
lineNumberActive: palette.mauve,
119120
matchingBracket: `${palette.surface2}47`,

src/cm/themes/tokyoNight.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export const config = {
1111
cursor: "#c0caf5",
1212
dropdownBackground: "#1a1b26",
1313
dropdownBorder: "#414868",
14-
activeLine: "#24283b",
14+
// Keep this translucent: CodeMirror draws selections behind line backgrounds.
15+
activeLine: "#6a83ce20",
1516
lineNumber: "#414868",
1617
lineNumberActive: "#a9b1d6",
1718
matchingBracket: "#24283b",

src/cm/themes/tomorrowNight.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export const config = {
1212
cursor: "#AEAFAD",
1313
dropdownBackground: "#1D1F21",
1414
dropdownBorder: "#4B4E55",
15-
activeLine: "#282A2E",
15+
// Keep this translucent: CodeMirror draws selections behind line backgrounds.
16+
activeLine: "#75778920",
1617
lineNumber: "#4B4E55",
1718
lineNumberActive: "#C5C8C6",
1819
matchingBracket: "#282A2E",

src/cm/themes/tomorrowNightBright.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export const config = {
1212
cursor: "#9F9F9F",
1313
dropdownBackground: "#000000",
1414
dropdownBorder: "#343434",
15-
activeLine: "#2A2A2A",
15+
// Keep this translucent: CodeMirror draws selections behind line backgrounds.
16+
activeLine: "#D2D2D233",
1617
lineNumber: "#343434",
1718
lineNumberActive: "#DEDEDE",
1819
matchingBracket: "#2A2A2A",

src/cm/themes/vscodeDark.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export const config = {
1212
cursor: "#c6c6c6",
1313
dropdownBackground: "#202020",
1414
dropdownBorder: "#454545",
15-
activeLine: "#282828",
15+
// Keep this translucent: CodeMirror draws selections behind line backgrounds.
16+
activeLine: "#67676720",
1617
lineNumber: "#6e7681",
1718
lineNumberActive: "#cccccc",
1819
matchingBracket: "#add6ff26",

tests/unit/editorThemes.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,16 @@ describe("built-in editor themes", () => {
6161
).not.toThrow();
6262
}
6363
});
64+
65+
it("keeps active-line backgrounds translucent so selections remain visible", () => {
66+
for (const { id } of getThemes()) {
67+
const activeLine = getThemeConfig(id).activeLine;
68+
if (!activeLine) continue;
69+
70+
expect(activeLine, `${id} active line`).toMatch(/^#[\da-f]{8}$/i);
71+
expect(Number.parseInt(activeLine.slice(-2), 16), `${id} active line`).toBeLessThan(
72+
255,
73+
);
74+
}
75+
});
6476
});

0 commit comments

Comments
 (0)