web: after a resync the Format sheet keeps a selection only where its words are
Fable's follow-up A on #181. When a resync's relative positions resolve to nothing (the refused change made the text), the old absolute positions stood in, but the rebuilt document can hold a change the page never saw (live updates are not taken while diverged), so they could point at other words. Now the kept selection's words and its block's words are recorded; the old positions stand in only where both still read the same, else the block with the same words nearest the old place is used, else the sheet closes (the editor asks phone.js to, with docs:format-sheet-close) and the keyboard does not come back for it. The selection is set with TextSelection.between (nit E). TestAResyncAfterACollaboratorsChange lands a collaborator's change on the server while holding the page's live fetch, then has a chip's save refused (413): with a line above the selection (remote-before.bin) the selection is kept over "Second paragraph."; with words written into it (remote-edit-second.bin, new) the sheet closes. Before this, the first drew the selection over "irst line." and the second over "Edited: Second pa".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 files changed,
+154
−35
fixtures/editor-entry.js+80 −23fixtures/generate-fragment.mjs+6 −0fixtures/vectors/fragment/remote-edit-second.binbinaryinternal/docs/brand/phone.js+3 −0internal/docs/phone_sheet_browser_test.go+51 −0internal/docs/static/{editor.470aeecd64ebb8df.js => editor.4db3c5911184ef23.js}+14 −12
fixtures/editor-entry.jsLoading diff…
fixtures/generate-fragment.mjsLoading diff…
fixtures/vectors/fragment/remote-edit-second.binLoading diff…
internal/docs/brand/phone.jsLoading diff…
internal/docs/phone_sheet_browser_test.goLoading diff…
internal/docs/static/{editor.470aeecd64ebb8df.js => editor.4db3c5911184ef23.js}Loading diff…