Behaviour SwRS-MDOKFSTUDIO-BLOCK-263
A block editor left without a change, or whose final save writes nothing, always closes
When a writer leaves a block editor by Done, Cmd/Ctrl+Enter, a click on another block or an arrow past the edge of the text box, the page SHALL compare and post the text of the text box with the line endings of the source block, so that text that differs from the source only by the LF the text box returns is the source again and posts no save, and the host SHALL answer every final save that ends with nothing to render by a previewEditSource message with done set, to which the page answers by closing the editor.
Part of StRS-MDOKFSTUDIO-BLOCK-006, outside the paths drawn on its map.
Scenarios 3
The situations the tests check; open one to read it.
nominalA text equal to the source but for its line endings is the source
| Input | Outcome |
|---|---|
| A block of a CR LF file (a hard-wrapped paragraph, a list item with nested items, the last item of a list), left by Done, Cmd/Ctrl+Enter, a click on another block or an arrow past the edge with no change | No previewEditSave is posted, the editor closes, "Saving Markdown…" is never shown |
| A letter typed then deleted in the same editor | No autosave and no final save: the text is the source again |
| The move chord (Cmd/Ctrl+Alt+Up or Down) on the same unchanged editor | The editor closes and the move is requested at once, with no save |
| A real change in the same editor | The text posted by the autosave and by the final save has the line endings of the source block |
| The same blocks in an LF file | Unchanged: LF |
nominalThe host answers every final save
| Input | Outcome |
|---|---|
| A final save whose text, once given the line endings of the block, equals the text last written (nothing to write) | The document is not written and the host posts previewEditSource with done true for that edit id |
| A final save the host writes and renders | The previewContentPatch is the answer; no done message |
| The page receives previewEditSource with done true for its open editor, which waits for a save | The editor closes and a pending move to another block goes on, as after a patch |
| The same message for another edit id, or for an editor that is not saving | Ignored |
| A cancel | No answer: the page closed the editor when it posted it |
boundaryMixed line endings
| Input | Outcome |
|---|---|
| A block with mixed line endings, left unchanged | Same as above: nothing is posted, nothing is written |
| The same block with one line changed | The lines left alone keep their line endings, the changed line takes the ending of the line it replaces |