Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-LIFE-003

Open Preview to Side opens or reveals a side preview

When a reader runs Open Preview to Side on a saved Markdown file, the extension SHALL show that file in the side preview that follows the active editor, by creating that preview beside the active editor when none is open and otherwise revealing it, and offer the command only for a resource whose extension is .md; the extension SHALL preview only a saved file with the extension .md, taken from the active editor (a text editor, a text diff, or the Studio Open With tab) or from a file URI the command receives, ignore an argument that is not a URI of the file scheme, and otherwise show the message Open a Markdown file to use Markdown OKF-Schema Studio. or the error Cannot open {path}: {reason} and open no preview.

Step 1 of path 1 in StRS-MDOKFSTUDIO-LIFE-001: from “A saved Markdown file is the active editor” to “A side preview is open beside the editor”.

Step 1 of path 1 in StRS-MDOKFSTUDIO-LIFE-003: from “A saved Markdown file is the active editor” to “A side preview shows the file”.

Scenarios 16

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

nominalEntry points of the command
Entry pointDeclaration
Commandmarkdown-okf-schema-studio.openPreview, title Open Preview to Side, category Markdown OKF-Schema Studio, icon $(book), enablement resourceExtname == .md
Command PaletteOpen Preview to Side and Refresh Preview, when resourceExtname == .md
Explorer context menuOpen Preview to Side, when resourceExtname == .md, group navigation
Editor title barthe book button, when resourceExtname == .md && (activeEditor == workbench.editors.files.textFileEditoractiveEditor == workbench.editors.textDiffEditor), group navigation; it runs Open Preview to Side
KeybindingCtrl+K Shift+V (Cmd+K Shift+V on macOS), when editorTextFocus && resourceExtname == .md
boundaryResource that is not offered the command
InputOutcome
the active resource is a file whose extension is not .mdthe command is disabled in the menus (deduced from the when clause, not run)
a .ts file in the active editor, the Command Palette openedneither command is listed (deduced from the when clause, not run)
a .json file in the Explorer, right-clickthe Explorer entry is absent (deduced from the when clause, not run)
a .md file shown in the Studio Open With editor, title bar drawnthe book button is absent, because the when clause requires the text file editor or the text diff editor (deduced from the when clause, not run)
focus in the terminal or in a non-Markdown editor, the chord pressedthe Studio does not handle it (deduced from the when clause editorTextFocus && resourceExtname == .md, not run)
nominalFirst preview
Givena saved Markdown file in the active editor and no Studio preview open
Whenthe reader runs Open Preview to Side
Thena preview panel opens beside the editor, titled Studio · preview.md, and renders the file (integration test test/integration/lifecycle.test.ts, first lifecycle render)
the command completes once the page shows the rendered document, not while it still shows the pending status page (host test test/host/openCompletes.test.ts)
with the active editor alone in the only editor group, the panel is requested with ViewColumn.Beside, so VS Code opens it in a new group to the side (deduced from the code, not run)
nominalThe shown document again
Givena side preview showing preview.md and preview.md in the active editor
Whenthe reader runs Open Preview to Side again
Thenno second panel opens; the existing panel is revealed and the document is rendered again
the command completes once the page shows that render (host test test/host/openCompletes.test.ts)
nominalAnother document
Givena side preview showing preview.md and preview-other.md in the active editor
Whenthe reader runs Open Preview to Side
Thenthe existing panel is revealed and switches to preview-other.md, after the page saved its open editors (see SwRS-MDOKFSTUDIO-BLOCK-205)
refusalNo eligible file
Giventhe active editor holds no saved Markdown file
Whenthe command runs
Thenthe side preview is left as it was and the file checks of the scenarios below apply
boundaryPreviews that do not follow the active editor
InputOutcome
an Open With preview tab of a.md, no side preview, a.md chosen in the Explorer, the Explorer entry runa new side preview panel is created beside the editor and the Open With tab stays
a panel restored by VS Code that is no longer the newest and has become a fixed preview, the command run from the Explorerthat panel is not reused
an Open With tab and a side preview of the same file, the command runonly the side preview that follows the active editor is reused
boundaryHidden preview
InputOutcome
a side preview with a scrolled page, hidden behind another tab of its group, the reader selects the preview tab againthe page is reloaded and restores its scroll position, edit state and comments panel from the saved webview state, because the panel is created without retainContextWhenHidden (deduced from the code, not run)
an Open With preview tab hidden behind another tab, selected againits page is restored the same way, because the custom editor is registered without retainContextWhenHidden
refusalNot a saved Markdown file
Givena TypeScript file in the active editor
Whenthe command runs from the Command Palette
Thenthe information message Open a Markdown file to use Markdown OKF-Schema Studio. shows and no preview opens
nominalStudio Open With tab active
Givena Studio Open With tab of a saved .md file is the active tab, so no text editor is active
Whenthe command runs from the Command Palette
Thenthe file of that tab opens in the side preview and no refusal message shows (the keybinding and the editor-title button are not offered while a custom editor has the focus)
nominalText diff active
Givena text diff is the active tab (a git diff, a two-file compare or the search and replace preview) and one side is a saved .md file of the file scheme, whichever side holds the cursor
Whenthe command runs from the Command Palette, the editor-title button or the keybinding, with no argument or with the URI of one side
Thenthat file, the real file of the diff, shows in the side preview, no text editor opens and no refusal message shows
with two .md files compared the side that holds the cursor is the real file (the modified side when none does)
with no side of the file scheme (a staged diff) the working-tree file at the modified side's path stands in when it exists and is .md, and otherwise the refusal message shows
refusalAnother custom editor active
Giventhe active tab is a custom editor of another type, so no text editor is active
Whenthe command runs from the Command Palette
Thenthe message Open a Markdown file to use Markdown OKF-Schema Studio. shows and no preview opens
boundaryEligible and ineligible files
InputOutcome
a file with the scheme file and the extension .mdpreviewed
README.MDaccepted: the extension check is case-insensitive
notes.markdownrefused with the message above
an untitled documentrefused with the message above
nominalFile passed by a menu
Givena side preview in group two, preview.md active, and preview-other.md chosen in the Explorer
Whenthe reader runs the Explorer entry Open Preview to Side on preview-other.md
Thenpreview-other.md opens as a permanent tab outside the preview's group, becomes the active editor and the side preview shows it (integration test test/integration/lifecycle.test.ts, the passed Uri is the active text editor)
without a side preview the file opens in the active group (by reading openPreview)
boundaryArgument that is not the file to open
InputOutcome
the URI names the file of the active editorthe file is not opened again and the active editor is previewed
the URI names a side of the active diffthe real file of the diff is previewed and no editor opens
the URI names a file that is no side of the active diffthe file opens as a text editor and is previewed, as without a diff
the argument { not: "a uri" } with a side preview of preview-other.mdignored; the preview still shows preview-other.md (integration test test/integration/lifecycle.test.ts)
a URI whose scheme is not fileignored the same way, because only the file scheme passes the check (deduced from the code, not run)
refusalA file that cannot be opened
InputOutcome
a file URI of a file deleted after the menu was drawnan error message Cannot open {path}: {reason} names the path and the reason, and no preview opens or changes
the failure is not an Error objectthe reason is the failure converted to a string

Implemented in 2

Tested by 8

Replaces

SwRS-MDOKFSTUDIO-LIFE-010Open Preview to Side checks the file it is given superseded superseded by SwRS-MDOKFSTUDIO-LIFE-003 Markdown file