Behaviour SwRS-MDOKFSTUDIO-BLOCK-117
The host swaps two blocks in one edit and keeps their separators
When the host moves a block past its neighbour, it SHALL replace only the lines from the first block to the second block with the swapped blocks, keeping the blank separator between them, the final line break and the line breaks of each block where they were, and adding a blank line only where the swap would glue a block to a non-blank line.
Step 2 of path 1 in StRS-MDOKFSTUDIO-BLOCK-014: from “The host is asked to swap the block with its neighbour” to “The two blocks are swapped in the document”.
Part of StRS-MDOKFSTUDIO-BLOCK-025, outside the paths drawn on its map.
Scenarios 6
The situations the tests check; open one to read it.
nominalSwap
Givena document `A`, blank line, `B` with a final line break and a move of B up
Whenthe host plans the move
Thenthe edit replaces the lines of both blocks with `B`, the blank line and `A`, the lines outside are untouched, and the new first line of each block is reported
boundaryThe separator is kept as it is
| Input | Outcome |
|---|---|
| Two blank lines between the blocks | Both blank lines stay between the swapped blocks |
| One blank line between the blocks | The same blank line stays between them |
boundaryThe line breaks of each block are kept
| Input | Outcome |
|---|---|
| A document with CR LF line breaks, two blocks swapped | Every line break of the result is CR LF; no LF appears where the original had CR LF |
| A block with a list and a block with a paragraph, swapped | Each keeps its own inner line breaks |
boundaryA blank line is added where the swap would glue a block
| Input | Outcome |
|---|---|
| Two blocks with no blank line between them, swapped | A blank line separates them in the result instead of merging them into one paragraph |
| A block that touched the block above it, moved down | A blank line is added so that it stays apart from its new neighbour |
nominalMoving down and then up restores the document
| Input | Outcome |
|---|---|
| Three blank-separated blocks, the first moved down and moved up again | The text equals the original |
| Blocks without a blank line, the same two moves | The added blank line stays, so the text differs (see the scenario above) |
boundaryA list mapped up to its trailing blank line
| Input | Outcome |
|---|---|
| A list followed by a blank line, sent with the range the renderer maps for it (the list's lines and that blank line), moved down or up past a heading | The blank lines at the end of the range are dropped first; the move is done and no "The preview is out of date" refusal is shown |
| A range that is only blank lines | Refused as a range that does not match the document |