Markdown OKF-Schema Studio

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
Givena side preview of preview.md
Whenthe reader makes preview-other.md the active editor
Thenthe preview shows Following the active Markdown editor., then the render of preview-other.md, and never the output of preview.md as the current one (integration tests test/integration/lifecycle.test.ts, second lifecycle render, and test/integration/sourceMapping.test.ts)
boundaryEditor changes that leave the preview as it was
InputOutcome
the active editor changes to the document the preview already showsnothing changes: no new render and the same requestId
the reader focuses package.json with a side preview of preview-other.mdthe 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 editorno new render is needed: the requestId is unchanged
nominalA text diff becomes active
Givena side preview of a.md that follows the editor
Whena text diff of b.md becomes the active tab (a git diff, a two-file compare or the replace preview), whichever side holds the cursor
Thenthe preview switches to the real file of the diff, b.md, as for a text editor
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
InputOutcome
a side preview of a.md and the multi-file diff editor (the changes view of several files) becomes the active tabthe 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 tabthe 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
InputOutcome
a side preview that follows and an Open With tab on another file, another Markdown file becomes activeonly the side preview switches
a restored older panel made a fixed preview and a newer following panel, another Markdown file becomes activeonly the newer panel switches
boundaryQuick switching between documents
InputOutcome
a side preview of A and a flush of the page's editors still running, the reader activates B then A before the flush endsthe 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 endsthe page's editor is watched again instead of the document being switched
nominalAnother workspace folder or trust state
Givena multi-root workspace and a side preview of a file in folder one
Whena file of folder two becomes active
Thenthe session of folder one is disposed, a new session is created on the same panel with followsActiveEditor and lockedColumn kept, and it starts from the Preview pending page
boundarySame folder and trust state, or no folder
InputOutcome
a side preview with restricted reads of a file in no workspace folder, another file of another directory also in no folder becomes activea new session is created too, because the resource folder is the document's own directory
the same document folder and trust statethe session is kept
boundaryA hidden preview that becomes visible
InputOutcome
a preview hidden while the editor scrolled to line 400, the reader selects the preview tabthe preview scrolls to line 400 (the editor's first visible line)
the preview was visible and only gained or lost focusno catch-up is sent and the preview keeps its position

Implemented in 4

Tested by 5

Known limits (1)