Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-REVIEW-119

Moved thread lines are written with the document save only

When the document is saved, the extension SHALL write the moved lines of the review threads to the comments file through the same write queue, and write that file only then and only when it exists, is valid and has no unsaved changes in an editor.

Part of StRS-MDOKFSTUDIO-REVIEW-001, outside the paths drawn on its map.

Part of StRS-MDOKFSTUDIO-REVIEW-003, outside the paths drawn on its map.

Step 2 of path 1 in StRS-MDOKFSTUDIO-REVIEW-008: from “The stored lines of the thread have moved” to “The comments file holds the new lines”.

Scenarios 7

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

nominalSave after moves
Giventhree threads that moved while the document was edited
Whenthe document is saved
Thenthe comments file holds the new lines of the three threads and the comments unchanged
boundaryNothing moved
Givena save when no thread moved
Whenthe document is saved
Thenthe file is not written
refusalSave never creates or repairs a comments file
InputOutcome
plain.md with no comments file is savedNo plain.comments.json is created
A comments file holding {bad and the document is savedThe file still holds {bad and no warning is shown
refusalComments file with unsaved changes
Givena comments file open with unsaved changes and threads that moved
Whenthe document is saved
Thenthe file on disk is unchanged and the warning "The review comments were not re-anchored in their file: notes.comments.json has unsaved changes in an editor." is shown once for each reason
a second save with the same reason does not show the warning again
the same comments file without unsaved changes receives the moved lines on save
nominalComments file shown or changed outside the editor
Givena comments file whose stored lines no longer fit the document
Whenthe file is shown or read after a change outside this editor
Thenevery thread is checked against the document text, and the threads are posted with the lines where their quotes are now and orphaned true for those not found
after a comment just written by the Studio, the lines followed in memory are the starting point of the check
boundaryDocument over 8 MiB
InputOutcome
A closed document of more than 8 MiB, the threads are readThe stored lines are posted without searching for the quotes
An open document of the same size, the threads are readThe open text is used
boundaryThe document changes while the save writes the lines
InputOutcome
A save that writes a moved thread (line 3 in the saved text) while two lines are added at the top of the buffer, after the comments file was read and before the write endsThe written lines are not shown as they are: the next post checks the anchor against the buffer and the page gets line 5
A save that writes the moved lines while the document does not changeThe written lines are shown without a new check

Implemented in 1

Tested by 3