fix(editor): darken Cursor theme selection background
This commit is contained in:
1 parent
bf3a475997
commit
ad1e5c9496
2 files changed
+32
-5
No files matched your search
+22
-1
@@ -1,5 +1,5 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
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 { DEFAULT_APP_CUSTOM_UI_COLORS, wcagContrastRatio, type AppThemePalette } from "@/lib/app/appTheme";
|
||||||
import type { EditorTheme } from "@/stores/settingsStore";
|
import type { EditorTheme } from "@/stores/settingsStore";
|
||||||
import { createDbxCodeMirrorSqlDialect } from "@/lib/editor/codemirrorSqlDialect";
|
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", () => {
|
describe("SQL completion theme", () => {
|
||||||
it("uses the configurable medium radius for the popup container", () => {
|
it("uses the configurable medium radius for the popup container", () => {
|
||||||
const rules = buildSqlCompletionThemeRules();
|
const rules = buildSqlCompletionThemeRules();
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ function createCustomTheme(EditorView: typeof import("@codemirror/view").EditorV
|
|||||||
return [theme, syntaxHighlighting(highlightStyle)];
|
return [theme, syntaxHighlighting(highlightStyle)];
|
||||||
}
|
}
|
||||||
|
|
||||||
type IdeEditorThemeColors = {
|
export type IdeEditorThemeColors = {
|
||||||
dark: boolean;
|
dark: boolean;
|
||||||
background: string;
|
background: string;
|
||||||
foreground: string;
|
foreground: string;
|
||||||
@@ -263,7 +263,7 @@ type IdeEditorThemeColors = {
|
|||||||
numberBold?: boolean;
|
numberBold?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const IDE_EDITOR_THEMES = {
|
export const IDE_EDITOR_THEMES = {
|
||||||
ideaLight: {
|
ideaLight: {
|
||||||
dark: false,
|
dark: false,
|
||||||
background: "#ffffff",
|
background: "#ffffff",
|
||||||
@@ -398,7 +398,10 @@ const IDE_EDITOR_THEMES = {
|
|||||||
dark: false,
|
dark: false,
|
||||||
background: "#fcfcfc",
|
background: "#fcfcfc",
|
||||||
foreground: "#141414eb",
|
foreground: "#141414eb",
|
||||||
selection: "#1414141e",
|
// Cursor/VS Code light `editor.selectionBackground`. The previous translucent
|
||||||
|
// neutral (#1414141e) composited to a near-background #e1e1e1 on the #fcfcfc
|
||||||
|
// canvas, so a mouse selection was barely visible.
|
||||||
|
selection: "#add6ff",
|
||||||
selectionMatch: "#14141411",
|
selectionMatch: "#14141411",
|
||||||
cursor: "#141414eb",
|
cursor: "#141414eb",
|
||||||
gutterBackground: "#fcfcfc",
|
gutterBackground: "#fcfcfc",
|
||||||
@@ -429,7 +432,10 @@ const IDE_EDITOR_THEMES = {
|
|||||||
dark: true,
|
dark: true,
|
||||||
background: "#181818",
|
background: "#181818",
|
||||||
foreground: "#e4e4e4eb",
|
foreground: "#e4e4e4eb",
|
||||||
selection: "#40404099",
|
// Cursor/VS Code dark `editor.selectionBackground`. The previous translucent
|
||||||
|
// neutral (#40404099) composited to #303030 on the #181818 canvas — visually
|
||||||
|
// almost indistinguishable from the editor background.
|
||||||
|
selection: "#264f78",
|
||||||
selectionMatch: "#404040cc",
|
selectionMatch: "#404040cc",
|
||||||
cursor: "#e4e4e4eb",
|
cursor: "#e4e4e4eb",
|
||||||
gutterBackground: "#181818",
|
gutterBackground: "#181818",
|
||||||
|
|||||||
Reference in new issue
Block a user