Skip to content

fix: keep code colours after Ctrl+L or copying a code line - #113

Merged
ttncode merged 2 commits into
mainfrom
fix/code-colours-after-line-keys
Dec 1, 2026
Merged

ttncode merged 2 commits into
mainfrom
fix/code-colours-after-line-keys

Conversation

@ttncode

@ttncode ttncode commented Dec 1, 2026

Copy link
Copy Markdown
Owner

Problem

Pressing Ctrl+L in a coloured code block (or Ctrl+C with nothing selected) turned the block into plain text.

Cause

Both shortcuts first split the code block into one <pre> per line (#splitCodeAtSelection, added in #112). The split makes new text nodes, but the syntax colours are CSS highlight ranges on the old ones, and they are only repainted by #changed(). Select line and copy return without calling it.

Fix

#splitCodeAtSelection repaints the colours after it splits. Other line keys already went through #changed().

Also releases v0.1.3.

Testing

  • node --test tests/*.test.js: 247 pass.
  • Not checked in a running app; the unit-test DOM has no CSS Custom Highlight API. Try Ctrl+L and Ctrl+C in a Markdown code block before tagging.

@ttncode
ttncode merged commit 3e990af into main Dec 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants