Behaviour SwRS-MDOKFSTUDIO-LIFE-170
A new page starts each view choice from the panel, stored or default value
When a page opens, the extension SHALL start each view choice from the saved panel state, else the stored workspace value, else the default of that choice, except the theme mode, which starts from the stored workspace value before the saved panel state.
Step 2 of path 2 in StRS-MDOKFSTUDIO-LIFE-014: from “The view choice is stored” to “The page opens with the view choice”.
Step 1 of path 2 in StRS-MDOKFSTUDIO-BLOCK-001: from “A document is opened in a new preview” to “The preview opens in the edit mode last chosen”.
Scenarios 7
The situations the tests check; open one to read it.
nominalOrder of sources for each view choice
The panel state is the state the webview saved with the panel (restored panel or rebuilt page). The stored value is the choice kept for the workspace (see SwRS-MDOKFSTUDIO-LIFE-169). A value of the wrong type or outside the accepted set is skipped and the next source is used.
| View choice | Panel state (first) | Stored value (second) | Default (last) | Accepted values and normalisation |
|---|---|---|---|---|
| Edit mode | saved editMode true, of the same document | none: the stored edit mode is not applied at start (see SwRS-MDOKFSTUDIO-LIFE-172) | off (preview mode) | a saved value that is not true, or saved by another document, gives off |
| Palette mode | saved paletteMode | the host gives the valid mode stored for the workspace, else the value of the setting markdownOkfSchemaStudio.editing.defaultPaletteMode | gfm | only strict, gfm, myst and full |
| Width mode | saved viewWidthMode | stored widthMode | margin | only margin, auto and full |
| Zoom | saved viewZoom | stored zoom | 100 | rounded to a multiple of 10 and clamped to 70 to 200; a value that is not a finite number is ignored |
| Toolbar rows 2 to 4 | saved viewToolbarCollapsed, a boolean | stored toolbarCollapsed | collapsed | only the stored value false expands, so a missing value gives collapsed |
| Contents column | saved viewToc, a boolean | stored toc, open only when true | closed | a saved non-boolean is ignored |
| Comments button | saved viewComments, a boolean | stored comments, hidden only when false | shown | a saved non-boolean is ignored |
| Anchor mode | saved anchorToEditor, a boolean | no stored value: the setting markdownOkfSchemaStudio.preview.scrollPreviewWithEditor | the setting value | a saved non-boolean is ignored |
| Theme mode (exception) | saved previewThemeMode (second) | stored previewThemeMode (first) | cream | only current, dark, white and cream |
nominalThe saved panel state wins
| Input | Outcome |
|---|---|
| Saved edit mode true of the same document | edit mode is on |
| Saved edit mode false, or no saved state | edit mode is off |
| Saved paletteMode myst and host initial mode strict | the palette mode is myst |
| Saved width mode full and stored width mode auto | the width mode is full |
| Saved viewZoom 120 and initial preference 150 | the zoom is 120 |
| Saved toolbar state collapsed and stored choice expanded | the toolbar is collapsed |
| Workspace preference toc open and saved state closed | the column is closed; with no saved state it would be open |
| Saved viewComments false | the gray chips are hidden and the Comments button is not pressed |
| Saved anchor mode off and setting on | the anchor mode is off |
nominalThe stored value or the setting applies without a saved state
| Input | Outcome |
|---|---|
| Preview in a trusted workspace whose stored edit mode is true | the page still starts in preview mode |
| Stored palette mode myst and setting strict | the initial mode in the page context is myst |
| Initial zoom preference 150, no saved state | the zoom is 150 |
| Stored zoom 130 accepted from a preview (validation and storage: SwRS-MDOKFSTUDIO-LIFE-169), next page of the workspace built | its initial view preferences carry the zoom 130 and, without saved state, it starts at 130 |
| Preview at 130 %, window reloaded, or preview closed and reopened | the zoom is still 130 |
| Stored toolbar choice expanded, no saved state | the toolbar is expanded |
| No webview state and the comments preference false | the gray chips are hidden |
| No saved anchor mode and setting off | the anchor mode is off; with the setting on it is on |
| Workspace that stored current, dark, white or cream in turn | the html attribute data-sphinx-preview-theme-mode equals the stored mode in each case, and current is kept as a choice, not replaced by Cream |
| Restored panel whose saved state holds white and a workspace without a stored mode | the theme mode is white |
| Restored panel whose saved state holds white and a workspace that stored dark | the theme mode is dark: the stored workspace mode wins over the saved state |
nominalA fresh workspace opens on the defaults
The Cream start is the same on a light and on a dark host theme:
| Input | Outcome |
|---|---|
| Fresh workspace, light VS Code theme, 900 px pane (visual scenario theme-zoom/v12) | the html attribute data-sphinx-preview-theme-mode is cream, the Theme button label is "Preview theme: Cream theme", its tooltip is "Cream theme (click for current theme)", the body background is rgb(245, 241, 232) and the text colour is rgb(43, 42, 39) |
| Fresh workspace, dark VS Code theme, 460 px pane (visual scenario theme-zoom/v13) | the page is the same light cream paper; the host theme is not visible |
refusalAn invalid value is ignored and the next source is used
| Input | Outcome |
|---|---|
| Stored edit mode false, absent or not a boolean | the page starts in preview mode |
| Preview with restricted reads whose stored edit mode is true | the page starts in preview mode |
| Invalid stored width mode and no saved state | the invalid value is ignored and the width mode is margin |
| Stored palette mode that is not a mode and setting strict | the initial mode is strict |
| No saved state and no host initial palette mode | the palette mode is gfm |
| Workspace storage holding the text sepia under the theme mode key | no stored mode is returned, the boot context of the next page carries none, and the page shows Cream |
| Workspace storage holding white | white is returned as the stored theme mode |
| Saved zoom of the text big and initial zoom 150 | the saved value is ignored and the zoom is 150 |
| Boot context whose toolbarCollapsed is missing | the toolbar is collapsed, because only the value false expands it |
boundaryZoom is rounded to the grid and clamped
| Input | Outcome |
|---|---|
| Page: saved zoom 133, then 300, then 10 | the zoom is 130, 200 and 70 |
| Host: stored zoom values 10, 69, 104, 105, 133 and 300 | the workspace preferences give 70, 70, 100, 110, 130 and 200 |
| Host: stored zoom of the text big or NaN, or stored preferences that are not an object | the zoom is 100 |
| Neither saved state nor initial preference | the zoom is 100 |
boundaryStarting on a default posts nothing, and a saved anchor mode that differs is posted once
| Input | Outcome |
|---|---|
| Fresh workspace, preview page starts and the runtime is installed | the page posts no previewThemeModeChanged message and no previewViewPreferenceChanged message, and the toolbar start posts no preference or theme message |
| The same page, Theme button clicked once | exactly one previewThemeModeChanged message is posted, carrying the new mode |
| Saved anchor mode off and setting on | one previewAnchorModeChanged message with anchorToEditor false is posted without a press |
| Saved anchor mode equal to the setting | nothing is posted |
Implemented in 13
- src/core/configuration/editingConfiguration.ts
- src/core/state/previewTheme.ts
- src/core/state/previewViewPreferences.ts
- src/page/features/anchorMode.ts
- src/page/features/themeMode.ts
- src/page/modules/commentsToggle.ts
- src/page/modules/tocColumn.ts
- src/page/modules/toolbarCollapse.ts
- src/page/modules/viewControls.ts
- src/page/modules/widthMode.ts
- src/page/runtime.ts
- src/session/features/rendering.ts
- src/session/workspaceChoices.ts
Tested by 14
- test/core/configuration/editingConfiguration.test.tsunit
- test/core/state/previewTheme.test.tsunit
- test/core/state/previewViewPreferences.test.tsunit
- test/integration/lifecycle.test.tsintegration
- test/integration/paletteMode.test.tsintegration
- test/integration/reload-suite.tsintegration
- test/page/diagReq.themeZoom.requirements.test.tsunit
- test/page/modules/commentsToggle.test.tsunit
- test/page/modules/tocColumn.test.tsunit
- test/page/runtimeEditPalette.test.tsunit
- test/page/runtimePageControls.test.tsunit
- test/page/runtimeScroll.test.tsunit
- test/session/diagReq.viewState.requirements.test.tsunit
- test/visual/capture_layout_checks.pyvisual