Behaviour SwRS-MDOKFSTUDIO-CODE-008
Diff blocks show additions and deletions
When a `diff` or `patch` block is shown, the extension SHALL mark each line starting with `+` as an addition and each line starting with `-` as a deletion, keeping the literal markers, and display the block as a full-width panel with square corners and no border.
Step 1 of path 2 in StRS-MDOKFSTUDIO-CODE-001: from “A document holds a diff block” to “Additions and deletions are marked in a full-width panel”.
Scenarios 6
The situations the tests check; open one to read it.
nominalAdditions and deletions are marked
Givena `diff` block with one `+` line, one `-` line and one context line
Whenthe preview renders it
Thenthe `+` line shows as an addition, the `-` line as a deletion and the context line is unmarked, all with their markers
boundaryThe first character decides the mark
| Line | Outcome |
|---|---|
| `+x` | Addition, marker kept in the text |
| `-x` | Deletion, marker kept in the text |
| `--- a/f` (file header) | Deletion, like an ordinary `-` line |
| `+++ b/f` (file header) | Addition, like an ordinary `+` line |
| context line starting with a space | Unmarked |
| empty line | Unmarked |
| `@@ -1 +1 @@` | Unmarked |
| `diff --git` header line | Unmarked |
A two-file diff has two deletion and two addition lines; `patch` blocks are marked the same way as `diff` blocks.
nominalThe panel is full width, square and borderless
Givena `diff` block in a prose paragraph context
Whenthe preview renders it
Thenthe panel spans the block width with square corners and no border
boundaryA nested diff block keeps the look
Givena `diff` block nested in a list or admonition
Whenthe preview renders it
Thenthe panel spans its container width with the same square, borderless look
nominalForced-colours mode uses system colours
Givenforced-colours mode is active and a diff block is shown
Whenthe preview renders it
Thenadditions use the system Mark colours and deletions the system Highlight colours
boundaryOutside forced-colours mode the theme colours apply
Givenforced-colours mode is inactive
Whenthe preview renders the same block
Thenthe theme-aware addition and deletion colours apply instead
Implemented in 2
Tested by 3
Replaces
SwRS-MDOKFSTUDIO-CODE-009Colour diff file header lines like ordinary lines superseded superseded by SwRS-MDOKFSTUDIO-CODE-008 Markdown file
SwRS-MDOKFSTUDIO-CODE-010Use system colours for diff lines in forced-colours mode superseded superseded by SwRS-MDOKFSTUDIO-CODE-008 Markdown file
SwRS-MDOKFSTUDIO-CODE-036Show diff blocks as a full-width square panel superseded superseded by SwRS-MDOKFSTUDIO-CODE-008 Markdown file