…selections
computeSelectionData() located the rendered selection in the raw markdown
with a verbatim indexOf. When the selection spanned syntax the renderer
strips (inline marks, link targets, list/table/heading markup, block
separators), there was no verbatim match and the function fell back to a
proportional length-ratio estimate, storing start_index/end_index that
point at unrelated text while the highlight still looked correct.
Replace the estimate with a markdown-syntax-tolerant matcher: content
characters must match exactly and in order (raw whitespace never stands
in for anchor content, so words cannot fuse), inline markup and link and
image tails are skipped between characters, and whitespace gaps absorb
block, list, table, and fence markup. The stored span starts at the
anchor's first content character and ends after its last, so it selects
exactly the source the user anchored to.
When the selection genuinely cannot be located, store an empty (0, 0)
placeholder span - the HTML viewer convention - keeping the comment
usable through anchor_content, the primary locator, instead of storing a
guessed range.
Summary
replace the proportional fallback with a markdown-syntax-tolerant matcher that finds the true raw span (content chars must match exactly and in order; inline markup, link/image tails, and block/list/table/fence markup are skipped), and store an empty (0,0) placeholder span - the HTML viewer convention, anchor_content stays the primary locator - when the selection genuinely cannot be located; commit 73ca157 on fix/omni-2882
Root Cause
computeSelectionData() in web/src/shell/TipTapEditorHelpers.ts located the rendered selection in the raw markdown with a verbatim indexOf; when the selection spanned syntax the renderer strips (inline marks, link targets, list/table/heading markup, block separators) it fell back to a proportional length-ratio estimate, storing start_index/end_index that point at different text than the anchored selection
Validation
Demo
Recordings: none — corrected outcome is purely textual (stored start_index/end_index read back from the comments API); the visible journey is identical before and after because the highlight always re-located from anchor_content - before/after stored spans are quoted in the evidence and belong in the PR Demo section
Issues
Closes #4598
Resolves OMNI-2882