Behaviour SwRS-MDOKFSTUDIO-BLOCK-058
Every host source edit is one undo step, renders once and reports a failed apply
When the host writes an edit of the source document for the preview, it SHALL make the edit one undo step, refresh the preview once for it, and answer an edit that VS Code does not apply or rejects with a reason that begins "VS Code could not apply" or with the text of the error.
Step 2 of path 1 in StRS-MDOKFSTUDIO-BLOCK-025: from “The typed text is in the document” to “The edit is one undo step with the line endings kept”.
Scenarios 8
The situations the tests check; open one to read it.
nominalOne undo step per edit kind
| Edit kind | How it is written | One Undo restores |
|---|---|---|
| Text of a block editor session (several autosaves and the final save) | Plain document edits without undo stops of their own, merged by VS Code | The block as it was before the session |
| Block move | Own undo stops in the text editor that shows the document | The previous order of the blocks |
| Block cut | Own undo stops in the text editor that shows the document | The blocks that were cut |
| Block paste | Own undo stops in the text editor that shows the document | The document before the paste |
| Checkbox toggle | Own undo stops in the text editor that shows the document | The original source |
| Reply to an inline thread | Own undo stops in the text editor that shows the document | The document as before the reply |
| Delete of an inline thread | Own undo stops in the text editor that shows the document | The thread is back |
| Frontmatter save (value save, add, rename, remove) | Exactly one text edit passed to the document | The document to its text before the save |
| Label rename | Own undo stops in the text editor that shows the document | The document before the rename |
nominalCancelled session
Givenan autosaved block edit that was cancelled
Whenthe host restores the original text
Thenthe restore is itself an ordinary edit
nominalNo visible text editor
Givena document shown only in the preview, with no text editor showing it
Whena move, a cut, a paste or a checkbox toggle is applied
Thenthe edit is applied as a workspace edit, one undoable step, with no undo stops of its own
nominalOne render after the final save
Givena block edit whose autosave changed the document and a final save with the same text
Whenthe final save completes
Thenthe preview is refreshed once, with the pin of the save
boundaryNothing applied
Givena held edit for which no autosave changed the document
Whenits final save carries the original text
Thenno render is started
refusalAn edit that VS Code does not apply or rejects
| Edit kind | VS Code does not apply the edit | VS Code rejects the edit or a clipboard access fails | Held edit |
|---|---|---|---|
| Block save (autosave or final save) | The editor shows "VS Code could not apply the Markdown edit." and the final request is reset | The editor shows the text of the error | Kept for a new save |
| Block move | Answer ok false with "VS Code could not apply the move." | Answer ok false with the text of the error | None |
| Block cut | Answer ok false with "VS Code could not apply the cut." | Answer ok false with the text of the error | None |
| Block paste | Answer ok false with "VS Code could not apply the paste." | Answer ok false with the text of the error | None |
| Block copy | Not applicable, nothing is written | A failing clipboard write answers ok false with the text of the error | None |
| Checkbox toggle | Answer with the error "VS Code could not apply the checkbox edit." | Answer with the text of the error | None |
| Label rename | Answer ok false with "VS Code could not apply the rename." | Answer ok false with the text of the error | None |
| Reply or delete of an inline thread | Answer ok false with "VS Code could not apply the change." | Answer ok false with the message of the error | None |
| Frontmatter save | Answer "VS Code could not apply the frontmatter edit." | Answer with the error message text | The document stays unchanged and the editor stays open with the message |
refusalA block that changed under the host
Givenan autosave to write and a block whose text was changed in the document meanwhile
Whenthe host is about to write
Thenthe editor shows "The source block changed while it was being edited." and the lock is released while the editor stays open
boundaryA block that did not change
Giventhe block still equals the last written text
Whenthe host writes
Thenthe replacement is applied
Implemented in 3
Tested by 8
- test/host-vscode/documents.test.tsunit
- test/host/fmtableReq.requirements.test.tsunit
- test/integration/blockClipboard.test.tsintegration
- test/integration/blockMove.test.tsintegration
- test/integration/checkboxToggle.test.tsintegration
- test/integration/inlineThread.test.tsintegration
- test/integration/previewEditing.test.tsintegration
- test/session/blockReq.requirements.test.tsunit
Replaces
SwRS-MDOKFSTUDIO-FMEDIT-053A save VS Code rejects is reported superseded superseded by SwRS-MDOKFSTUDIO-BLOCK-058 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-055Each frontmatter save is one document edit superseded superseded by SwRS-MDOKFSTUDIO-BLOCK-058 Markdown file
SwRS-MDOKFSTUDIO-GFM-022A checkbox toggle is one undo step superseded superseded by SwRS-MDOKFSTUDIO-BLOCK-058 Markdown file