Behaviour SwRS-MDOKFSTUDIO-LIFE-100
Scrolling the text editor scrolls the preview to the same line
When the text editor of a previewed document, or the side of a text diff that is that document's file, scrolls while the anchor mode is on, the extension SHALL record the editor's first visible line as the anchor of each preview of that document, owned by the editor, and scroll the preview so that this line sits at its reading line, without reporting that scroll back to the editor.
Step 1 of path 1 in StRS-MDOKFSTUDIO-LIFE-010: from “The editor and the preview show the same document” to “The preview shows the line of the editor”.
Scenarios 10
The situations the tests check; open one to read it.
nominalHost records the editor's first visible line
Givena side preview of the file and the anchor mode on
Whenthe text editor scrolls to its line 40 and the visible range changes
Thenthe preview's anchor is line 40 with the editor as owner and the host posts sourceScroll to the page
nominalPage scrolls to the editor line
Givena preview and a text editor of the same file, anchor mode on, the editor scrolled to line 120
Whenthe page receives sourceScroll with line 120
Thenthe page takes line 120 as its anchor, owned by the editor, and the preview scrolls so that line 120 starts at its reading line below the sticky heading band
refusalScroll that is not followed
| Input | Outcome |
|---|---|
| the anchor mode off and the editor-selection mark off, and the editor scrolls | the anchor is not recorded and nothing is posted |
| sourceScroll whose line is below 1 | the anchor and the scroll position are unchanged |
| sourceScroll whose line is not a finite number | the anchor and the scroll position are unchanged |
| sourceScroll that names another render | refused by the host message acceptance rule, see SwRS-MDOKFSTUDIO-TRUST-059 |
nominalThe page's own scroll is not reported
Givena page that scrolled to line 120 for a sourceScroll
Whenthe resulting scroll event arrives within 500 ms and within 2 px of the target
the reader scrolls the preview afterwards
the reader scrolls the preview afterwards
Thenno previewScroll is posted, so the editor is not scrolled back
the page takes the anchor as owner preview and reports it
the page takes the anchor as owner preview and reports it
boundaryThe host ignores the editor scroll that its own reveal caused
| Input | Outcome |
|---|---|
| the host revealed line 80 while the editor top was line 10, and the editor reports first visible lines 40 and 80 within 0.5 seconds | both are echoes and do not move the preview (they lie between the start and the target line) |
| a reveal that leaves the editor top outside the range, and the editor reports one event with the revealed line visible | that single event is accepted as an echo; further scrolling counts as the reader's |
| an editor report after the 0.5 second window | not an echo; it moves the preview |
nominalThe pane the reader moved owns the anchor
| Input | Outcome |
|---|---|
| the editor scrolled, then the reader scrolls the preview | the preview is the owner of the anchor and the owner changes without the preview jumping; the source wheel moves independently of the drag |
| the editor scrolled elsewhere after the preview reported line 30, then the reader scrolls the preview to line 30 again | the preview reports line 30 again |
boundaryWhich preview knows whether a text editor shows its file
| Input | Outcome |
|---|---|
| a solo preview and the reader opens the file in a text editor (the visible editors change) | the page receives previewPairing with pairedTextEditor true (see SwRS-MDOKFSTUDIO-TOOLBAR-120 for the Anchor button) |
| the text editor is closed (the visible editors change) | the page receives pairedTextEditor false |
| a preview without a rendered stage when the visible editors change | it receives nothing |
| a pairing change posted while the page document was still loading, then the page reports ready | the host posts previewPairing with the current value (the colour theme answer to the ready report is SwRS-MDOKFSTUDIO-THEME-016) |
| a page that applied a content patch reports ready | it gets the same answer |
| a host whose capabilities say editorPairing is false looks for the editor of a preview | none is found, no preview is paired and the Anchor button stays disabled |
| VS Code looks for the editor of a preview | visible editors whose document id equals the preview's document are paired |
nominalReading, edit and block-editor modes, with and without a text editor
| Input | Outcome |
|---|---|
| a 4000 line document, the preview and a text editor side by side, anchor mode on; the reader scrolls either pane down and up in reading mode, edit mode or with a block editor open | the other pane follows to the same place |
| anchor mode off, or no text editor of the file; the reader scrolls either pane | the other pane stays still, the document is not edited and a block editor stays open |
nominalThe side of a text diff
| Input | Outcome |
|---|---|
| a side preview of a.md and a text diff whose side of the file scheme is a.md, that side scrolls to line 40 | the preview scrolls to line 40, as for a text editor |
| the other side of the diff (a git or virtual document at the same path) scrolls | the preview does not move |
| a diff with no side of the file scheme | the preview does not move |
boundaryDefaults and the setting off
| Input | Outcome |
|---|---|
| No stored value for markdownOkfSchemaStudio.preview.scrollPreviewWithEditor, settings and page boot context read | The setting is true (on by default); a boot entry that is absent or not false reads as on |
| scrollPreviewWithEditor set to false and the writer scrolls the text editor | The preview stays where it is; the Anchor button overrides the setting for one panel |
Implemented in 4
Tested by 12
- test/core/scroll/anchorPolicy.test.tsunit
- test/host/diffPreview.requirements.test.tsunit
- test/host/lifeReq.requirements.test.tsunit
- test/integration/diffPreview.test.tsintegration
- test/integration/diffPreviewScroll.test.tsintegration
- test/integration/scroll-sync-suite.tsintegration
- test/integration/sourceMapping.test.tsintegration
- test/page/pageSettings.test.tsunit
- test/page/runtimeBundle.test.tsunit
- test/page/runtimeContentPatch.test.tsunit
- test/page/runtimeScroll.test.tsunit
- test/session/lifeReq.requirements.test.tsunit
Replaces
SwRS-MDOKFSTUDIO-LIFE-097Two settings decide how the panes follow each other superseded superseded by SwRS-MDOKFSTUDIO-LIFE-100, SwRS-MDOKFSTUDIO-LIFE-108 Markdown file