Behaviour SwRS-MDOKFSTUDIO-FMEDIT-043
A frontmatter edit changes only the lines of its field
When a writer saves a value, the extension SHALL change only the lines of that field and keep comments, quoting style, spacing, fences, body and line endings byte-identical, and refuse an edit that would leave a block that does not parse or whose keys are not exactly the expected ones.
Part of StRS-MDOKFSTUDIO-FMEDIT-005, outside the paths drawn on its map.
Step 1 of path 1 in StRS-MDOKFSTUDIO-FMEDIT-008: from “A field editor is open” to “The value is saved on the lines of its field and the diff holds only the edited field”.
Scenarios 6
The situations the tests check; open one to read it.
nominalA value edit changes only its field
Givena document with a trailing comment on the title line and other fields
Whentitle is changed from Alpha to Beta
Thenonly the title line changes and its comment is kept
boundaryLine endings, fences and values that look like a fence
| Document | Edit | Outcome |
|---|---|---|
| CRLF endings | a value is changed | only the named field's lines change; the fences, body and line endings stay identical |
| closing fence of three dots | a value is changed | the closing fence is kept and only the edited line changes |
| title: To be continued... and status: draft | status is changed | exactly the status line changes and the block keeps its three keys (a value ending in ... or --- stays inside the block) |
nominalAn added field is one inserted line in the file's line endings
Givena CRLF document with the fields title and status
Whenowner is added after title
Thenthe edit inserts exactly one line ended by CRLF
boundaryAn added list uses the compact sequence style
Givenan added list value
Whenthe field is written
Thenthe list uses the compact sequence style
boundaryAnchored or aliased values rewrite the whole block with the right data
| Block | Edit | Outcome |
|---|---|---|
| a: &x 1 and b: 3 | a is set to 2 | the block parses to a: 2 and b: 3 |
| a value that is edited as an object | saved | the written block parses to the same data |
refusalAn edit that loses or corrupts a key is refused
| Patch checked by the patch guard | Outcome |
|---|---|
| deletes the author key | refused, no edit is applied; the host answers "The frontmatter YAML could not be updated." |
| duplicates the status key | refused, no edit is applied; the same answer |
| leaves invalid YAML | refused |
| a faithful patch of the status line | passes unchanged |
Implemented in 2
Tested by 7
- test/core/frontmatter/frontmatterFence.test.tsunit
- test/core/frontmatter/frontmatterPreservation.test.tsunit
- test/core/frontmatter/okfFrontmatter.test.tsunit
- test/core/frontmatter/okfFrontmatterPatches.test.tsunit
- test/core/frontmatter/sameData.holes.test.tsunit
- test/integration/previewEditing.test.tsintegration
- test/integration/realInput/qa210Replays.tsintegration
Replaces
SwRS-MDOKFSTUDIO-FMEDIT-039An added field is a single inserted line in the file's line endings superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-043 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-044Anchored or aliased values fall back to a whole-block rewrite superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-043 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-045A frontmatter edit that loses or corrupts a key is refused superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-043 Markdown file
SwRS-MDOKFSTUDIO-FMEDIT-046Values ending in three dots or dashes stay inside the block superseded superseded by SwRS-MDOKFSTUDIO-FMEDIT-043 Markdown file