fix(editor): darken Cursor theme selection background

This commit is contained in:
dadong authored and GitHub committed 2026-09-28 21:05:01 +08:00
1 parent bf3a475997
commit ad1e5c9496
2 files changed
+32 -5

No files matched your search

+22 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { buildEditorFontThemeRules, buildSqlCompletionThemeRules, editorDiagnosticColors, editorThemeAppearanceFor, resolveCustomThemeBackgrounds, resolveEditorTheme, SQL_BUILTIN_HIGHLIGHT_TAG } from "@/lib/editor/editorThemes";
import { buildEditorFontThemeRules, buildSqlCompletionThemeRules, editorDiagnosticColors, editorThemeAppearanceFor, IDE_EDITOR_THEMES, resolveCustomThemeBackgrounds, resolveEditorTheme, SQL_BUILTIN_HIGHLIGHT_TAG } from "@/lib/editor/editorThemes";
import { DEFAULT_APP_CUSTOM_UI_COLORS, wcagContrastRatio, type AppThemePalette } from "@/lib/app/appTheme";
import type { EditorTheme } from "@/stores/settingsStore";
import { createDbxCodeMirrorSqlDialect } from "@/lib/editor/codemirrorSqlDialect";
@@ -150,6 +150,27 @@ describe("custom editor theme backgrounds", () => {
});
});
describe("Cursor editor theme selection", () => {
// The Cursor palettes track Cursor/VS Code's own `editor.selectionBackground`
// (#264F78 dark, #ADD6FF light). They previously used translucent neutrals
// (#40404099 over #181818, #1414141e over #fcfcfc) which composited to #303030 /
// #e1e1e1 — visually almost identical to the editor background, so a mouse
// selection was hard to spot.
it("paints the selection opaque and clearly visible on the editor background", () => {
const dark = IDE_EDITOR_THEMES.cursorDark;
const light = IDE_EDITOR_THEMES.cursorLight;
expect(dark.selection).toBe("#264f78");
expect(light.selection).toBe("#add6ff");
// Opaque, so the highlight cannot wash out against the editor background.
expect(dark.selection).toMatch(/^#[0-9a-f]{6}$/);
expect(light.selection).toMatch(/^#[0-9a-f]{6}$/);
// Selected text must stay legible inside the highlight.
expect(wcagContrastRatio(dark.foreground, dark.selection), `cursor-dark text on selection`).toBeGreaterThanOrEqual(3.0);
expect(wcagContrastRatio(light.foreground, light.selection), `cursor-light text on selection`).toBeGreaterThanOrEqual(3.0);
});
});
describe("SQL completion theme", () => {
it("uses the configurable medium radius for the popup container", () => {
const rules = buildSqlCompletionThemeRules();