Behaviour SwRS-MDOKFSTUDIO-LIFE-026
The side preview follows the active Markdown editor
When another saved Markdown file becomes the active editor, or a text diff whose real file is another saved Markdown file becomes the active tab, the extension SHALL switch only the newest side preview that follows the editor to that file, show Preview pending with the message Following the active Markdown editor. until its render ends, apply only the last requested document when the editor changes during the switch, and leave the preview unchanged for any other editor change.
Step 2 of path 1 in StRS-MDOKFSTUDIO-LIFE-003: from “A side preview shows the file” to “The preview shows the newly active file”.
Scenarios 9
The situations the tests check; open one to read it.
nominalSecond file
boundaryEditor changes that leave the preview as it was
| Input | Outcome |
|---|---|
| the active editor changes to the document the preview already shows | nothing changes: no new render and the same requestId |
| the reader focuses package.json with a side preview of preview-other.md | the preview keeps its document, status and requestId, with no reload (integration test test/integration/lifecycle.test.ts, 750 ms bounded sleep) |
| the reader returns to the Markdown editor | no new render is needed: the requestId is unchanged |
nominalA text diff becomes active
a move of the cursor between the sides of the same diff, a diff with no side of the file scheme (a stand-in) and a diff whose real file is the shown document switch nothing
boundaryEditors the side preview does not follow
| Input | Outcome |
|---|---|
| a side preview of a.md and the multi-file diff editor (the changes view of several files) becomes the active tab | the preview keeps its document: that editor is not followed |
| a side preview of a.md and the merge editor (3-way merge) becomes the active tab | the preview keeps its document: that editor is not followed |
The reason is the VS Code API: it gives these two editors no tab input class (only the text, text diff, custom, notebook and similar classes exist), so the host cannot tell them from another editor and reads them as an editor change that leaves the preview unchanged. Open the file in a text editor or in the single-file text diff to preview it (documented in docs/known-limitations.md and docs/user/open-studio.md).
boundaryOnly the newest following preview switches
| Input | Outcome |
|---|---|
| a side preview that follows and an Open With tab on another file, another Markdown file becomes active | only the side preview switches |
| a restored older panel made a fixed preview and a newer following panel, another Markdown file becomes active | only the newer panel switches |
boundaryQuick switching between documents
| Input | Outcome |
|---|---|
| a side preview of A and a flush of the page's editors still running, the reader activates B then A before the flush ends | the preview ends on A and does not switch to B |
| an editor of A is open in the page and the reader returned to A before the switch ran, the flush ends | the page's editor is watched again instead of the document being switched |
nominalAnother workspace folder or trust state
boundarySame folder and trust state, or no folder
| Input | Outcome |
|---|---|
| a side preview with restricted reads of a file in no workspace folder, another file of another directory also in no folder becomes active | a new session is created too, because the resource folder is the document's own directory |
| the same document folder and trust state | the session is kept |
boundaryA hidden preview that becomes visible
| Input | Outcome |
|---|---|
| a preview hidden while the editor scrolled to line 400, the reader selects the preview tab | the preview scrolls to line 400 (the editor's first visible line) |
| the preview was visible and only gained or lost focus | no catch-up is sent and the preview keeps its position |
Implemented in 4
Tested by 5
Known limits (1)
- a session replaced because the next document needs another resource root or trust state starts with an empty remembered-state map, so the reading state of earlier documents is not brought back after such a switch.