Markdown OKF-Schema Studio

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
InputOutcome
Two blank lines between the blocksBoth blank lines stay between the swapped blocks
One blank line between the blocksThe same blank line stays between them
boundaryThe line breaks of each block are kept
InputOutcome
A document with CR LF line breaks, two blocks swappedEvery 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, swappedEach keeps its own inner line breaks
boundaryA blank line is added where the swap would glue a block
InputOutcome
Two blocks with no blank line between them, swappedA blank line separates them in the result instead of merging them into one paragraph
A block that touched the block above it, moved downA blank line is added so that it stays apart from its new neighbour
nominalMoving down and then up restores the document
InputOutcome
Three blank-separated blocks, the first moved down and moved up againThe text equals the original
Blocks without a blank line, the same two movesThe added blank line stays, so the text differs (see the scenario above)
boundaryA list mapped up to its trailing blank line
InputOutcome
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 headingThe 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 linesRefused as a range that does not match the document

Implemented in 2

Tested by 3