Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-BLOCK-234

Preview edits keep the line endings of the document

When the extension plans or writes back a preview edit, it SHALL treat LF, CR LF and a lone CR as line ends, count one more empty last line after a final line break, and keep the line ending that the edited text ended with, write the line breaks inside an edited multi-line block with the one line ending the block (or, for a block of one line, the document) already uses, including the CR LF endings of a table and the presence or absence of its final line ending.

Another outcome at step 2 of path 1 in StRS-MDOKFSTUDIO-BLOCK-025, in the state “The typed text is in the document”.

Scenarios 5

The situations the tests check; open one to read it.

nominalA save restores the trailing line ending of the block
Original block text ends withText posted by the save
LFthe text box content plus the same LF
CR LFthe text box content plus the same CR LF
CRthe text box content plus the same CR
no line ending (a block at the end of a file without a final line break)the text box content with no trailing line break either
nominalA multi-line block keeps its line ending when saved
InputOutcome
A block of several lines in a CR LF document, a line added in the text box (which returns LF)The lines written to the document, the new one included, end with CR LF
The same in a document whose lines end with a lone CRThe lines written end with CR
The same in a document with LF line breaksThe lines written end with LF
A block of one line, or the last block of a file without a final line break, in a CR LF or lone-CR documentThe lines written end with the one line ending of the document
A block whose line endings are mixed (a text that already holds a CR is written as it is)The lines the edit left alone keep their line endings; a changed line takes the ending of the line it replaces (the line above when lines were added or removed)
A document with mixed line endings when the block has no line breakThe text box content is written as it is
nominalA CRLF table keeps its line endings
InputOutcome
a CRLF table with a trailing line ending and a row inserted, then written backall lines, the new one included, end with CRLF and the trailing line ending is kept
the same table with one cell edited, then written backthe line endings are unchanged
a CRLF table without a trailing line endingthe absence of the final line ending is kept
nominalA save on a real CRLF, LF or mixed file changes the block only
InputOutcome
A paragraph or a list saved in a document read from a file with CR LF line endings (with or without a final line break), LF line endings, or bothEvery byte outside the block is the one of the file; the block keeps its own line ending
Any of these saves in a CR LF fileNo bare LF is added
Any of these saves in an LF fileNo CR is added
boundaryCounting lines
InputOutcome
a document `a\r\nb\nc\rd` and an edit that names line 4the edit lands on `d`, because the text has four lines a, b, c and d
the text `a\n` and an edit that names line 2line 2 exists and is empty

Implemented in 4

Tested by 11