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
refusalExcluded folder
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
| Input | Outcome |
|---|---|
| exactly 20 bibliography files | all 20 are taken and the list is not marked truncated |
| more bibliography files than 20 | at most 20 files are taken and the list is marked truncated |
| bibliography files of 3 MiB together | files 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 read | the file is skipped and the other files still count; the scan does not fail |
| a search that takes longer than 5 seconds | the 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 time | the timer is cleared |
nominalEntries of the list
boundaryDuplicates and cap of the list
| Input | Outcome |
|---|---|
| the same key in two files | the key appears once and the first file that defines it wins |
| more than 1000 keys | the list is cut at 1000 with truncated true |
refusalFailed scan, restricted reads and stale preview
| Input | Outcome |
|---|---|
| a scan that throws an Error | previewListCitationsResult holds ok false and the reason is the message of the error |
| a scan that throws a value that is not an Error | ok false and the reason is that value as a string |
| one unreadable file among readable ones | the 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 render | ok 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 characters | ignored 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.