Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-TOOLBAR-059

Followed links and anchor jumps are recorded per panel and replayed at their line

When the reader follows a link to another Markdown document in a preview that follows the active editor, or an anchor of the shown document that resolves to a source line, the extension SHALL record the place in the history of that panel (at most the 50 newest places, no duplicate of the current place, the places after the current one dropped), and when Back or Next leads to a recorded place, open its document with the stored line selected or scroll the preview to the stored line.

Step 2 of path 1 in StRS-MDOKFSTUDIO-TOOLBAR-009: from “The typed text is saved” to “The place is recorded”.

Scenarios 13

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

nominalLink to another Markdown document
Givena preview of first.md at line 3 and a link to second.md#target
Whenthe link is followed
Thenthe history holds the place being left, first.md at line 3, and then second.md at the first line of its selection (the line of the heading), the current index is the target and Back becomes possible
boundaryUnknown line
Givena preview that never reported a line
Whena link is followed
Thenthe place left is recorded at line 1
nominalIn-page anchor jump
Givenanchors #target (a heading) and #note-label (a MyST label)
Wheneach is followed
Theneach adds one history entry at its source line (5 and 9 in the fixture)
refusalMoves that are not recorded
InputOutcome
An anchor whose id has no source line, such as a generated idThe preview still scrolls but no history entry is added (an entry is added only when markdownFragmentRange finds a line)
A link to notes.txt or another local file whose extension is not .mdThe file opens in the editor and the history is unchanged
A link to NOTES.MDIt is recorded, because the extension is compared in lower case
A link to second.md followed in a locked preview (one that does not follow the active editor)second.md opens and the history is unchanged
An in-page anchor followed in the same locked previewThe jump is recorded
nominalBack or Next to another document
Giventhe history first.md line 3 then second.md
WhenBack is pressed
Thenfirst.md opens with line 3 selected and the preview follows it; Next opens the second document with its line restored
boundaryLine past the end
Givena stored line larger than the document
WhenBack is pressed
Thenthe last line is selected (selection line = min(max(stored line, 1), line count) minus 1)
nominalBack or Next within the same document
Giventhe history holds two places of second.md and an older scroll anchor of the preview
WhenBack is pressed
Thenno document is opened, the preview receives a sourceScroll to the stored line, and the preview's scroll anchor becomes the stored line, owned by the editor, so a stale anchor cannot overwrite it
boundaryAnchor mode off
Givena panel whose Anchor mode is off and a history of two places of the same document
WhenBack is pressed
Thenthe history moves, the buttons update and the preview scrolls to the stored line, because the sourceScroll of a history move carries reveal true, which the page honours when it does not follow the editor
nominalOne history per panel
Giventwo preview panels
Whenlinks are followed in the first
Thenthe second panel's Back and Next stay disabled; a document switch that recreates the session of a panel keeps the same history object, which lives as long as the panel
boundary51st distinct place
Givena history of 50 places
Whenanother distinct place is pushed
Thenit still holds 50 places, the oldest is gone and the newest is current
nominalNew place after Back
GivenWhenThen
a history of three places at the seconda new place is pushedthe third place is gone, Next is not possible and the new place is current
a history at its last placea new place is pushednothing is dropped
refusalDuplicate of the current place is not added
GivenWhenThen
a current place second.md line 5second.md line 5 is pushedthe history keeps its length
a current place second.md line 5the same document at line 6 is pushedit is added
a jump inside the current documentit is recordedthe number of places does not grow
nominalLeaving a place
GivenWhenThen
a current entry first.md line 1 and the reader at line 8 of first.mda jump startsthe current entry becomes line 8 and no entry is added
a current entry of the same document and no known linea jump startsthe entry keeps its line and no entry is added
a current entry of another document and a place of first.md with no linea jump startsfirst.md is pushed at line 1

Implemented in 3

Tested by 5

Replaces

SwRS-MDOKFSTUDIO-TOOLBAR-065The history keeps the last 50 places without duplicates superseded superseded by SwRS-MDOKFSTUDIO-TOOLBAR-059 Markdown file