Skip to content

Fix selection ranges that start with whitespace - #279

Open
happykawayigt wants to merge 1 commit into
hyperaudio:mainfrom
happykawayigt:fix/selection-leading-whitespace
Open

Fix selection ranges that start with whitespace#279
happykawayigt wants to merge 1 commit into
hyperaudio:mainfrom
happykawayigt:fix/selection-leading-whitespace

Conversation

@happykawayigt

Copy link
Copy Markdown

Summary

Fixes #64 by deriving the shared media fragment from spans that contribute actual non-whitespace selection text.

Changes

  • intersect the selection range with each timed span before choosing boundaries
  • ignore spans where the intersection contains only whitespace
  • remove the leading-space index adjustment that could skip the first selected word
  • regenerate the ESM build and add regression coverage

Validation

  • node scripts/build-mjs.js
  • full Jest suite: 3 suites passed, 75 tests passed
  • direct jsdom reproduction: selection " two thr" resolves to 2.00,3.50 instead of 3.00,3.50
  • git diff --check

@happykawayigt
happykawayigt marked this pull request as ready for review July 30, 2026 19:22
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.

A text selection which starts with an empty space, results in example.org/#hypertranscript=NaN,NaN

1 participant