Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-PALETTE-183

The host scans nearby bibliography files for citation keys within bounds

When the host answers previewListCitations, the extension SHALL search the .bib files of the folder of the document first and then of its workspace folder outside the folders node_modules, .git, _build, .venv, venv, out and dist, read at most 20 files within 2 MiB and 5 seconds, and answer the unique entry keys sorted, at most 1000, each with its title, marking the list truncated when any bound cuts it, or answer ok false with the message of the error when the scan fails.

Part of StRS-MDOKFSTUDIO-PALETTE-013, outside the paths drawn on its map.

Scenarios 6

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

nominalNearest first
Givena .bib file next to the document and another in a sibling folder
Whenthe scan runs
Thenboth keys are listed and the file next to the document is read first
refusalExcluded folder
Givena .bib file under node_modules
Whenthe scan runs
Thenits keys are not listed

The skipped folders are node_modules, .git, _build, .venv, venv, out and dist; the search uses the glob **/*.bib with that exclusion list.

boundaryBounds of the scan
InputOutcome
exactly 20 bibliography filesall 20 are taken and the list is not marked truncated
more bibliography files than 20at most 20 files are taken and the list is marked truncated
bibliography files of 3 MiB togetherfiles are read only while their total size stays within 2 MiB; the files that do not fit are skipped and the list is marked truncated
a file that cannot be readthe file is skipped and the other files still count; the scan does not fail
a search that takes longer than 5 secondsthe search is cancelled, no more file is read, and the list holds the keys read so far with truncated true
a search that ends in timethe timer is cleared
nominalEntries of the list
Givena file with the entries smith2024 and jones-2020 and a comment entry
Whenthe keys are read
Thenthe two keys are listed sorted (English locale comparison) with their titles (clipped to 80 characters), and the comment, string and preamble entries are skipped
boundaryDuplicates and cap of the list
InputOutcome
the same key in two filesthe key appears once and the first file that defines it wins
more than 1000 keysthe list is cut at 1000 with truncated true
refusalFailed scan, restricted reads and stale preview
InputOutcome
a scan that throws an ErrorpreviewListCitationsResult holds ok false and the reason is the message of the error
a scan that throws a value that is not an Errorok false and the reason is that value as a string
one unreadable file among readable onesthe scan does not fail and the other keys are answered
a preview with restricted reads (an untrusted workspace, or a file outside every workspace folder)ok false with the reason "Listing citations searches the workspace for .bib files, which needs a trusted workspace folder that holds this file."; no file is read (SwRS-MDOKFSTUDIO-TRUST-005)
a document that is no longer the one of the renderok false with the reason The preview is out of date. Try again once it has refreshed.
a previewListCitations message without a non-empty editId of at most 100 charactersignored by the envelope check

Each answer repeats the editId and holds ok true with the items (value and label are the key, the detail is the title) and the truncated flag; see SwRS-MDOKFSTUDIO-TRUST-052, SwRS-MDOKFSTUDIO-TRUST-005, SwRS-MDOKFSTUDIO-TRUST-065 and SwRS-MDOKFSTUDIO-TRUST-090.

Implemented in 3

Tested by 3