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
| Input | Outcome |
|---|
| A tracked file whose shown text has two lines changed since HEAD | the page receives two ranges of the changed lines, 1-based, in the shown text |
| A tracked file with an unsaved edit in the editor | the edited lines are in the ranges |
nominalWhen the marks are posted
| Trigger | Outcome |
|---|
| The preview renders | the marks are posted 300 ms later; a second render within 300 ms replaces the pending refresh, so only one post follows |
| The HEAD commit changes | the marks are read again and posted at once |
| Trust is granted to a preview opened in an untrusted workspace | the marks are posted at once |
| The preview settings change | the marks are posted at once |
| A page has just loaded | the marks are posted at once |
| The Diff choice is stored | the marks are posted at once (see SwRS-MDOKFSTUDIO-REVIEW-214) |
refusalAn untracked file, another scheme, an untrusted workspace or an off choice
| Input | Outcome |
|---|
| A file that Git does not know, with no mark showing | no 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 unchanged | nothing is posted |
| A page that shows marks and a file that Git no longer knows or a workspace that is no longer trusted | an empty list of ranges is posted so the page clears the marks |
boundaryNothing to say and marks to take back
| Input | Outcome |
|---|
| No changed lines, no marks showing and the enabled value equal to the one last posted | no message is posted |
| A page that shows marks and a document that now equals HEAD | an empty list is posted |
| A page that shows marks and the Diff choice turned off | an empty list is posted |
nominalAdded, modified and separate edits
| Input | Outcome |
|---|
| A base and a current text with two lines added | the added lines are reported in the line numbers of the current text |
| One modified line | one range |
| Two separate edits | two ranges |
| Identical texts | no range |
boundaryDifferences that do not count
| Input | Outcome |
|---|
| A base with LF and a current text with CRLF | no range is reported |
| A base without a final newline against one with it | no range is reported |
| A current text with lines removed and nothing added | no range is reported |
boundaryRange size limits
| Input | Outcome |
|---|
| 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
| Input | Outcome |
|---|
| A shown text of more than 1 MiB | nothing is returned |
| A document that is not a file | nothing is returned |
| A file whose HEAD text is longer than 1 MiB (a big blob) | nothing is returned |
nominalA new HEAD commit is announced
| Input | Outcome |
|---|
| A state change that moves HEAD to a new commit | the listener is called with the new commit id, once per commit change |
| A state change with the same commit id | no listener call is made |
| No repository, no Git extension or no active API | no listener call is made |