Skip to content

Let the changed-word highlight be a background, an underline or off - #31

Merged
dgsienko merged 2 commits into
dgsienko:mainfrom
bwets:feat/word-highlight-style
Nov 20, 2026
Merged

dgsienko merged 2 commits into
dgsienko:mainfrom
bwets:feat/word-highlight-style

Conversation

@bwets

@bwets bwets commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

What

A setting for how changed words inside a modified line are shown:

  • Background: today's filled highlight, still the default.
  • Underline: a 2px underline in the text color, no fill. Easier on the eyes over the green and red line backgrounds.
  • Off: no word marks, only the line colors.

It sits under "Changed words" in Settings (a segmented control, like the diff mode switch) and in the command palette as "Cycle changed-word highlight". It is saved in settings.json as word_highlight.

How

  • SettingsUpdate.word_highlight accepts background, underline or off, and AppState loads and saves it like word_wrap.
  • _apply_word_highlights emits <mark class="word-hl">, so the new rules leave the plain <mark> of the search dialog alone.
  • useAppearance puts word-hl-background, word-hl-underline or word-hl-off on <html>, and style.css styles mark.word-hl from it. No new colors: the underline uses currentColor.
  • mark.word-hl has no side padding. The generic mark rule adds 0 1px, which shifted the rest of a marked line by 2px per mark against the other side of the split view.

Tests

  • test_settings_roundtrip covers word_highlight set to underline and to off.
  • The _apply_word_highlights cases expect the word-hl class.

pytest (319 passed), ruff check and ruff format --check are clean. Checked by hand in the web UI: each option restyles the open diff at once and survives a reload.

Version bumped to 0.12.0. This is independent of #30, which bumps to 0.11.3, so whichever merges second only needs the version line resolved.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xshwvphn2wQmVKLLS2G9kJ

The word marks inside a paired remove/add line were always a filled
orange background. A new word_highlight setting (background, underline,
off) picks how they look. It is a segmented control under "Changed
words" in Settings and a "Cycle changed-word highlight" palette command.

The marks now carry class="word-hl", so the styling no longer touches
the plain <mark> the search dialog uses, and they drop the 1px side
padding the generic mark rule adds, which pushed the rest of a marked
line off the columns of the other side.

Bump version to 0.12.0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xshwvphn2wQmVKLLS2G9kJ
@bwets
bwets requested a review from dgsienko as a code owner November 20, 2026 13:56
@bwets
bwets marked this pull request as draft November 20, 2026 13:59
bwets added a commit to bwets/diffui that referenced this pull request Nov 20, 2026
The end-to-end test looked for a bare <mark>old</mark>. Matching on
">old</mark>" still proves the mark starts on the changed word, and
keeps passing if the mark gains a class, as dgsienko#31 does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xshwvphn2wQmVKLLS2G9kJ
@bwets
bwets marked this pull request as ready for review November 20, 2026 14:06
…-style

# Conflicts:
#	AGENTS.md
#	pyproject.toml
@dgsienko
dgsienko merged commit 0c85248 into dgsienko:main Nov 20, 2026
4 checks 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