Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-LIFE-032

Refresh Preview renders the shown document again

When a reader runs Refresh Preview, by the command or by the Refresh button, the extension SHALL render the document of the newest live preview again from its buffer, unsaved text included, doing nothing when the active text editor shows another document.

Step 1 of path 2 in StRS-MDOKFSTUDIO-LIFE-003: from “A side preview shows the file” to “The preview shows the text of the buffer, unsaved text included”.

Part of StRS-MDOKFSTUDIO-LIFE-005, outside the paths drawn on its map.

Scenarios 8

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

boundaryCommand declaration
InputOutcome
the package manifest, the contributed commands are readmarkdown-okf-schema-studio.refreshPreview has the title Refresh Preview, the category Markdown OKF-Schema Studio and the enablement resourceExtname == .md, and no icon
the active resource is not a .md filethe command is disabled (deduced from the when clause, not run)
nominalDirty buffer
Givena preview of preview-other.md and a buffer edited by an API edit without a save
Whenthe reader runs Refresh Preview
Thena new render with a higher requestId shows the edit marker
the command completes once the page shows that render (host test test/host/openCompletes.test.ts)
nominalOver an open editor
Givenan inline editor open in the page
Whenthe command runs
Thenthe render replaces the page even then (see SwRS-MDOKFSTUDIO-BLOCK-041)
refusalOther document
Giventhe newest preview shows preview.md and the active text editor shows preview-other.md
Whenthe reader runs Refresh Preview
Thenno render starts and no message appears
boundaryWhich preview the command acts on
InputOutcome
no text editor is active, for example the preview itself has focus, and the command is run from codethe newest preview's own document is rendered again
a side preview and a later Open With tab of the same fileonly the Open With tab, the newer session, renders again
the newest preview is closedthe newest remaining preview is the target
nominalButton pressed
Givena page scrolled to line 120 with two open sections, a link tooltip open and nothing being edited
Whenthe reader presses Refresh
Thenthe page closes the tooltip and posts previewRefresh carrying sourceLine, scrollTop, anchorLine, openDisclosures and descriptionsCollapsed
refusalButton pressed over an open editor
Givena block editor is open
Whenthe reader presses the button
Thennothing is posted and the editor's status line asks to save or cancel (see SwRS-MDOKFSTUDIO-BLOCK-041)
boundaryThe previewRefresh message
InputOutcome
a previewRefresh with the envelope (documentId, revision, requestId) and any of line, endLine, sourceLine and selectionLine (safe integers of at least 1), anchorLine (a finite number of at least 1), scrollTop (a finite number of at least 0), previewThemeMode, anchorToEditor, editMode (booleans) and request (a string); focusedBlockId, selectedText, openDisclosures, descriptionsCollapsed and activation are reported state that is not validatedaccepted as a message (see SwRS-MDOKFSTUDIO-TRUST-052)
a previewRefresh with an invalid optional field, or one that belongs to another type (a pin, blockEditOpen, final, a checkbox column or a frontmatter field)not a message, ignored (see SwRS-MDOKFSTUDIO-TRUST-052)
a page of the current render reporting state and a refreshthe state is recorded for the document and a new render replaces the page, even over an open editor
the message names an older render than the host holdsdropped without any render (see SwRS-MDOKFSTUDIO-TRUST-065)

Implemented in 4

Tested by 7