Skip to content

Fix secondary highlight handling for partial selections - #117

Merged
githubSINGLE merged 1 commit into
opensourcefrom
codex/fix-115-highlight-selection
Aug 18, 2026
Merged

Fix secondary highlight handling for partial selections#117
githubSINGLE merged 1 commit into
opensourcefrom
codex/fix-115-highlight-selection

Conversation

@k-undurkhaan-2

Copy link
Copy Markdown
Collaborator

Summary

  • Require an exact selection of one primary highlight before promoting it to the secondary color
  • Treat partial, mixed, multiple-highlight, and already-secondary selections as deterministic no-ops while clearing stale toolbar state
  • Preserve adjacent and nested-inline primary/secondary ranges during snapshot restore
  • Add Chromium regression coverage for selection boundaries and persistence

Root cause

updateSelectionToolbar() treated any Range.intersectsNode() result as a full highlight match, so applySelectionHighlight() recolored the entire span and discarded the saved range. Boundary-only contact also counted as overlap. Highlight restore additionally assigned seam offsets to the preceding text node and did not expand fully selected inline boundaries, causing adjacent or inline ranges to be lost.

Impact

Partial or cross-boundary selections no longer recolor unselected text or create nested highlights. Complete primary-highlight selections still promote to secondary, and resulting highlight levels survive snapshot/restore.

Validation

  • node developer/tests/js/readingInteractionRegression.test.js
  • npm test --prefix developer (72 tests)
  • python -m unittest discover -s developer/tests/py -p "test_*.py" (20 tests)
  • python developer/tests/ci/check_reading_data_integrity.py
  • python developer/tests/e2e/e2e_runner.py
  • node scripts/build-bundles.mjs --check
  • git diff --check

Fixes #115

Require exact single-span selections for secondary highlights and preserve adjacent or inline ranges during snapshot restore.

Refs #115

@githubSINGLE githubSINGLE left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all things look good to me

@githubSINGLE
githubSINGLE merged commit b48f204 into opensource Aug 18, 2026
2 checks passed
@githubSINGLE
githubSINGLE deleted the codex/fix-115-highlight-selection branch August 18, 2026 09:37
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