fix: make the composer caret more visible

Thickens the CodeMirror cursor to 2px
Adds a slight vertical scale so the caret stands out above glyphs
Covers the new cursor styling with a test
This commit is contained in:
Bohdan Triapitsyn
2026-08-10 15:10:37 +03:00
parent 2c30af5807
commit 5e26390ad2
2 changed files with 15 additions and 1 deletions
@@ -46,6 +46,14 @@ describe('composerEditorTheme', () => {
expect(rule.borderLeftColor.startsWith('var(--')).toBe(true);
});
test('the drawn caret is wide enough to remain prominent', () => {
const cursorRule = selectors.find((selector) => selector.includes('.cm-cursor'));
const rule = (COMPOSER_EDITOR_THEME_SPEC as Record<string, Record<string, string>>)[cursorRule!];
expect(rule.borderLeftWidth).toBe('2px');
expect(rule.transform).toBe('scaleY(1.15)');
expect(rule.transformOrigin).toBe('center');
});
/**
* CodeMirror's own `.cm-cursor` rule and its `&dark` override are one and
* two classes deep respectively; a bare `.cm-cursor` selector loses to the
@@ -30,7 +30,10 @@ export const COMPOSER_EDITOR_THEME_SPEC = {
// `caret-color: transparent !important` at the highest precedence and
// draws its own `.cm-cursor` element, whose base style is a hard-coded
// `border-left: 1.2px solid black`. Styling `caret-color` here therefore
// does nothing at all — the border is what has to be coloured.
// does nothing at all — the border is what has to be coloured. A 2px
// stroke makes the insertion point remain visible against every composer
// surface without relying on a fixed colour. A slight vertical scale makes
// it extend beyond the glyphs without changing CodeMirror's line geometry.
//
// CodeMirror recolours it for dark editors through `&dark .cm-cursor`,
// which needs the theme to declare itself dark. OpenChamber themes are not
@@ -43,6 +46,9 @@ export const COMPOSER_EDITOR_THEME_SPEC = {
// moment this module is imported.
'&.cm-editor .cm-cursor, &.cm-editor .cm-dropCursor': {
borderLeftColor: 'var(--surface-foreground)',
borderLeftWidth: '2px',
transform: 'scaleY(1.15)',
transformOrigin: 'center',
},
'.cm-line': { padding: '0' },
'.cm-scroller': {