Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-TABLE-094

Editing one cell changes exactly one line of the source

When a table is parsed and written back after a cell edit, a row insertion, a row deletion or no change, the extension SHALL change only the line the edit concerns, so that a cell edit changes one line, a new row adds one line, a deleted row removes one line and an unchanged table gives back exactly the original text; when a row is split into cells it SHALL accept rows with or without leading and trailing pipes, keep a pipe escaped with a backslash within its cell, and split a cell at every other pipe, also one inside a code span, as the preview does.

Another outcome at step 1 of path 2 in StRS-MDOKFSTUDIO-TABLE-013, in the state “A cell editor is open in a pipe table”.

Step 1 of path 1 in StRS-MDOKFSTUDIO-TABLE-014: from “A cell editor is open in a pipe table” to “Only the line of the cell is changed”.

Scenarios 15

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

nominalUnchanged table gives back the original text
Table written back with no changeOutcome
compactoutput equals the input
paddedoutput equals the input
no spacesoutput equals the input
alignedoutput equals the input
no outer pipesoutput equals the input
escaped pipe and pipe in a code spanoutput equals the input
indentedoutput equals the input
CRLF line endingsoutput equals the input
wider than the paddingoutput equals the input
CRLF table with an escaped pipe and a pipe in a code spanoutput equals the input
nominalOne edited cell changes one line
Givena padded table and a compact table, one body cell edited in each
the same two tables in a real window with the edit saved by Enter
Whenthe table is written back
the buffer is compared with the original
Thenone line is removed and one line is added, and it is the edited row; every other line, the delimiter row included, is verbatim
the diff is one line
nominalThe edited cell keeps its leading whitespace and its width
EditOutcome
the padded cell "first" edited to a slightly longer valuethe value fills the original cell width with trailing spaces, at least one
the same cell edited to a much longer valuethe value gets one trailing space
a cell emptied, in a padded tablethe table keeps its padding
an empty cell filled, in a padded tablethe table keeps its padding
a cell emptied or filled, in a compact tablesingle spaces
boundaryAny single cell edit parses again with that cell
InputOutcome
each header and body cell of every corpus table set to "" (the delimiter row is skipped)the rows equal the edited model and at most one line changed
the same cells set to "x"the rows equal the edited model and at most one line changed
the same cells set to a typed pipe between a and bthe pipe is saved escaped, the rows equal the edited model and at most one line changed
a cell set to the value it already holdsno line changes
nominalA new row takes the style of a neighbouring body row
Givena padded table and a row inserted after the first body row
a table written "a | b" without outer pipes and a row inserted after the first body row
Whenthe table is written back
the table is written back
Thenone padded line is added, with the padding of the nearest preceding body row, else the nearest following body row, else the header row
one parseable line "| | |" is added (the row is written with outer pipes) and the table parses again with the new empty row
nominalDeleting a row removes exactly one line
Givena compact table and its first body row deleted
Whenthe table is written back
Thenone line is removed and none is added and the other lines are verbatim
refusalThe header row is not deleted
Giventhe header row selected
Whena deletion is requested from the model
Thennothing is deleted
boundaryEdge cells of rows without outer pipes and indented tables
InputOutcome
a table "a | b" over "c | d" with the first cell of the body row emptiedthat row alone is rewritten canonically, keeping its indentation, the table parses with an empty cell and one line changed
the same table with the last cell of the body row emptiedthat row alone is rewritten canonically, the table parses with an empty cell and one line changed
rows with a leading pipe only or a trailing pipe only and an edge cell emptiedthe table still parses with the empty cell
a table whose rows are indented and one cell editedonly the edited row changes and its indentation is unchanged
the same indented table after Col +the indentation is lost (see SwRS-MDOKFSTUDIO-TABLE-055)
boundaryA row with text after its closing pipe
Givena table whose body row ends with a tail such as " ^row-a" after its closing pipe
Whenone cell of that row is edited
Thenonly that row's line changes and the tail stays at its end, and the table without an edit serialises to the same bytes, CRLF included
nominalRows without outer pipes
Giventhe rows "a | b", "| a | b" and "a | b |"
Wheneach is split
Theneach gives the cells a and b
boundaryTrailing pipe after a backslash
Givena row ending with \|
Whenit is split
Thenthe final pipe belongs to the last cell when the backslashes before it are odd in number
nominalEscaped pipe
Givena row "| Brake | x\|y |"
Whenit is parsed, and then written back unchanged
Thenthe cells are Brake and x\|y (the cell text holds the backslash) and the serialised row text is unchanged
nominalEscaped pipe in backticks
Giventhe row "| Brake | `a\|b` and x |"
Whenit is parsed for editing
Thenthe cells are Brake and `a\|b` and x (the preview shows a|b in the code span)
boundaryUnescaped pipe in backticks
Giventhe row "| `x|y` | z |" under a two-column table
Whenit is parsed for editing
Thenthe pipe splits the cell, as it does in the preview (GFM): the row has three cells, of which the editor keeps the first two (the same cells as the preview) and the third, with the closing pipe, as the row tail, so the editor and the preview hold the same cells
boundaryText after the closing pipe of a body row
Givena body row of a table of two columns with more cells than the header, such as "| alpha | 1 | ^row-a", "| alpha | 1 | {#row-c}", "| alpha | 1 | <!-- keep -->" or "| a | b | c |"
the same extra cell in the header or in the delimiter row
Whenit is parsed for editing
the table is parsed
Thenthe row has the header's two cells and a tail: the text after the closing pipe of the last column, kept verbatim ("| alpha | 1 |" and " ^row-a"; "| a | b |" and " c |"); the preview ignores the extra cells, as GFM does, and the serialised table is unchanged
it is no pipe table of the editor, as it is none in the preview

Implemented in 1

Tested by 4

Replaces

SwRS-MDOKFSTUDIO-TABLE-102Edge pipes are optional and only an escaped pipe stays in its cell superseded superseded by SwRS-MDOKFSTUDIO-TABLE-094 Markdown file