Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-LIFE-143

Closing a preview or folder leaves nothing behind

When a preview panel is closed, a document is closed, a workspace folder is removed or the extension is deactivated, the extension SHALL cancel the render queue and dispose the pending render stages, file watchers, subscriptions and Problems entries of the preview concerned, so that no late result reaches the panel, keeping every shared resource that another live preview still uses. A preview whose workspace folder is removed keeps its panel and shows its file with restricted reads.

Step 1 of path 1 in StRS-MDOKFSTUDIO-LIFE-022: from “A preview is open, rendering or idle” to “The preview has left nothing behind”.

Scenarios 7

The situations the tests check; open one to read it.

nominalClosed while rendering
Givena preview debouncing, building or awaiting a patch acknowledgement
Whenthe panel is closed
Thenthe preview stays silent: no message, no status and no stage is kept
nominalClosed idle
Givenan idle preview
Whenthe panel is closed
Thenthe session is removed from the live set and getActivePreviewForTests returns undefined
nominalWatchers removed
Givena preview that watches the files below its root
Whenthe panel is closed
Thenthe preview's hold on the watcher and its change, create and delete subscriptions are released, and the watcher itself is disposed with the last preview of that root (previews of one root share one watcher)
nominalProblems entries cleared
GivenProblems entries for a.md published by its only preview
Whenthe preview is closed, switches document or a.md is closed
Thenthe entries of a.md are deleted
nominalFolder removed
Givena preview with full reads of a file in a workspace folder (in the Agents window, the folder of the active agent session, which a session switch removes)
Whenthe folder is removed from the workspace
Thenthe preview's session, with its render queue, watchers and Problems entries, is disposed; the same panel stays open and shows the file in a new session with restricted reads (resource root = the directory of the file, no session roots) that keeps the reading state; the folder's files still exist
when a folder that holds the file is added later, the preview gets full reads again on the same panel (see SwRS-MDOKFSTUDIO-TRUST-001)
nominalDeactivation
Giventwo open previews
Whenthe extension host stops the extension
Thenthe preview sessions, watchers and the Problems collection are disposed, the panels stay and the serializer restores them at the next start
boundaryWhat stays after a close
CaseOutcome
A second preview of the same or another root, and the first is closedThe second keeps its watcher
A second live preview of a.md, and the first is closed or the document is closedThe Problems entries of a.md stay
A preview of a file that is in no workspace folder, and a folder is removedThe preview stays open, unchanged
A preview of a file in a removed folder that another workspace folder still holdsThe preview moves to a session of that folder, on the same panel
A preview of a removed folder that has no document to showThe preview and its panel are disposed
A preview of a removed folder with an open block, cell or field editorThe page is asked to save and close its editor first (previewFlushEdit), then the session is replaced: the typed text is kept
A session that was already disposed, and it is disposed again without its panelNothing happens: the disposal is idempotent

Implemented in 5

Tested by 5