Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-REVIEW-195

The host posts the lines that differ from the last commit, read from Git for small files

When the shown document is a file tracked by Git, in a trusted workspace, with preview.showIncomingChanges on and the Diff choice on, the extension SHALL post to the page the line ranges of the shown text, unsaved edits included, that differ from the file at HEAD, and in every other case post an empty list of ranges only to take back marks the page shows; it reports the added and modified lines of the shown text as 1-based ranges, merging adjacent lines and keeping separate edits as separate ranges, reports no range for a difference of line endings, of a missing final newline or of deleted lines only, and reports the whole differing middle as one range when more than 20 000 lines differ or more than 2000 edits are needed; it reads the text at HEAD through the built-in Git extension without starting a process, returns nothing when Git cannot give it or when the shown text, the document or the HEAD text is not a file under 1 MiB, and announces a change of the Git state only when the HEAD commit id has changed.

Step 1 of path 1 in StRS-MDOKFSTUDIO-REVIEW-017: from “A file tracked by Git differs from its last commit” to “The page holds the changed line ranges”.

Scenarios 11

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

nominalChanged lines and unsaved edits
InputOutcome
A tracked file whose shown text has two lines changed since HEADthe page receives two ranges of the changed lines, 1-based, in the shown text
A tracked file with an unsaved edit in the editorthe edited lines are in the ranges
nominalWhen the marks are posted
TriggerOutcome
The preview rendersthe marks are posted 300 ms later; a second render within 300 ms replaces the pending refresh, so only one post follows
The HEAD commit changesthe marks are read again and posted at once
Trust is granted to a preview opened in an untrusted workspacethe marks are posted at once
The preview settings changethe marks are posted at once
A page has just loadedthe marks are posted at once
The Diff choice is storedthe marks are posted at once (see SwRS-MDOKFSTUDIO-REVIEW-214)
refusalAn untracked file, another scheme, an untrusted workspace or an off choice
InputOutcome
A file that Git does not know, with no mark showingno incoming-change message is posted
A file that is not a file document, a workspace that is not trusted, or the setting or the Diff choice off, with no mark showing and the enabled value unchangednothing is posted
A page that shows marks and a file that Git no longer knows or a workspace that is no longer trustedan empty list of ranges is posted so the page clears the marks
boundaryNothing to say and marks to take back
InputOutcome
No changed lines, no marks showing and the enabled value equal to the one last postedno message is posted
A page that shows marks and a document that now equals HEADan empty list is posted
A page that shows marks and the Diff choice turned offan empty list is posted
nominalAdded, modified and separate edits
InputOutcome
A base and a current text with two lines addedthe added lines are reported in the line numbers of the current text
One modified lineone range
Two separate editstwo ranges
Identical textsno range
boundaryDifferences that do not count
InputOutcome
A base with LF and a current text with CRLFno range is reported
A base without a final newline against one with itno range is reported
A current text with lines removed and nothing addedno range is reported
boundaryRange size limits
InputOutcome
A middle part of more than 20 000 lines (above the line cap)one range covers the whole middle
More than 2000 edits (above the edit budget)one range covers the whole middle
nominalGit available
Givena repository with the file in HEAD
Whenthe base is read
Thenthe commit id and the text are returned
refusalGit missing or failing
Givenno Git extension, no repository, no file in HEAD or a failing show
Whenthe base is read
Thennothing is returned and nothing is marked
boundaryOnly file documents under 1 MiB
InputOutcome
A shown text of more than 1 MiBnothing is returned
A document that is not a filenothing is returned
A file whose HEAD text is longer than 1 MiB (a big blob)nothing is returned
nominalA new HEAD commit is announced
InputOutcome
A state change that moves HEAD to a new committhe listener is called with the new commit id, once per commit change
A state change with the same commit idno listener call is made
No repository, no Git extension or no active APIno listener call is made

Implemented in 3

Tested by 4

Replaces

SwRS-MDOKFSTUDIO-REVIEW-200The line diff reports added and modified lines superseded superseded by SwRS-MDOKFSTUDIO-REVIEW-195 Markdown file
SwRS-MDOKFSTUDIO-REVIEW-203The HEAD text comes from the built-in Git extension for small files superseded superseded by SwRS-MDOKFSTUDIO-REVIEW-195 Markdown file