Behaviour SwRS-MDOKFSTUDIO-LIFE-119
Both panes share one reading anchor that survives updates
When a preview is scrolled, rebuilt, re-laid out or edited, the extension SHALL define its scroll anchor as a source line (the editor's first visible line, and the preview's line at its reading line below the sticky heading band, with the very top of the page always being line 1) and keep that anchor through the update.
Step 1 of path 2 in StRS-MDOKFSTUDIO-LIFE-010: from “The preview is scrolled to a reading line” to “The same source line stays at the reading line after the update”.
Scenarios 8
The situations the tests check; open one to read it.
nominalReading the anchor line
| Input | Outcome |
|---|---|
| a preview scrolled down the page | the anchor line is the line that starts at the reading line below the band, never the caret line; the editor top line is the floor of the anchor |
| a scroll position of 0 | the anchor line is line 1 |
nominalA line inside a long paragraph
| Input | Outcome |
|---|---|
| a paragraph of five source lines wrapped over twelve rendered lines, and source line 4 looked up | the position is the measured start of that line, not a proportional guess |
| a paragraph whose line starts cannot be measured reliably, and a line inside it looked up | the block's top and bottom bound the position |
nominalA new render starts at the last anchor
| Input | Outcome |
|---|---|
| a preview whose anchor is line 80, and a new render is built | its boot context carries initialAnchor 80 and the page applies it before the first paint |
| no anchor yet and a visible editor whose zero-based first visible line is 30, the first render is built | its initial anchor is line 31 in one-based numbering |
| no anchor yet and the follow setting off | no anchor is passed |
nominalLayout changes re-apply the stored anchor
| Input | Outcome |
|---|---|
| an image loads, the pane is resized, the content changes size, the sticky band changes or the zoom changes | the page scrolls again to the stored anchor line instead of re-reading it from the scroll position |
| a preview scrolled to the middle of a long document, and the reader cycles the width mode through auto, full and margin | the same heading stays within 40 px of where it was |
| a sticky band that appears while the page is scrolled | the content does not move |
| a scroll whose layout pass runs before the scroll is handled (a viewport resize reported with each scroll, as in a webview next to an editor) | the scroll sets the anchor first; the page stays where the reader scrolled |
| a pending scroll while blocks change position or height, such as a comment above the reading line closing | the stored anchor survives; the layout-induced scroll does not become a new reading position |
boundaryLines added or removed above the anchor
| Input | Outcome |
|---|---|
| an anchor at line 50 and two lines inserted at line 10 | the anchor of each preview of that document is line 52 |
| an edit at line 60 with the anchor at line 50 | the anchor stays line 50 |
nominalWhile a block or field editor is open
| Input | Outcome |
|---|---|
| an open block editor or frontmatter field editor whose text grows and the layout shifts | the edited element stays where it was on screen |
| an open block editor and the text editor scrolled explicitly | the preview follows, the editor stays open and the element's anchor is the new position |
nominalEvery mapped block carries its source mapping
Givena rendered document of a heading, paragraphs, an admonition and a figure
a figure directive and an element whose line attribute is 0, negative or not a number
a figure directive and an element whose line attribute is 0, negative or not a number
Whenthe host builds the page
the host builds the page
the host builds the page
Theneach element with a positive integer source line carries the source file, the source line, the document id and a block id source-block-1, source-block-2 and so on in document order; an element that spans several lines also carries its end line; no line is 0 or negative
the figure is keyboard-accessible with tabindex 0 (an element that is naturally focusable, or one that already carries a tabindex, keeps its own) and the invalid element gets no mapping attributes
the figure is keyboard-accessible with tabindex 0 (an element that is naturally focusable, or one that already carries a tabindex, keeps its own) and the invalid element gets no mapping attributes
refusalThe page measures only its own visible mapped blocks
| Input | Outcome |
|---|---|
| an element that names another document or another file | ignored for scrolling and anchors |
| a mapped element with display none | ignored |
| a mapping whose file path uses Windows separators | the backslashes are normalized and the document identity check still applies |
Implemented in 4
Tested by 8
- test/core/scroll/anchorPolicy.holes.test.tsunit
- test/core/scroll/anchorPolicy.test.tsunit
- test/integration/scroll-sync-suite.tsintegration
- test/integration/sourceMapping.test.tsintegration
- test/page/lifeReq.requirements.test.tsunit
- test/page/runtimeContentPatch.test.tsunit
- test/page/runtimeScroll.test.tsunit
- test/session/lifeReq.requirements.test.tsunit