fix(language-server): re-render instead of recompiling on a schedule change (audit B7) #64
No reviewers
Labels
No labels
bug
discussion
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gram-lang/gram!64
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/audit-b7"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Audit B7 (read in the code, not reproduced by the audit). Changing
gram.miseEnPlacecalledrefresh(uri, state.text, state.version)for every open document: a full reload of the module graph, parse, compile and diagnostics, to change two render options.Reproduced with a small LSP driver (a keystroke still waiting in the 150 ms debounce when the setting changes): the refresh runs with the cached text while the module graph reads the live buffer, so it produced an inconsistent state (
state.text= old text, version 1, but compilation of the new text) and stored it withstates.set. It was only replaced because the debounced refresh happened to finish after; a late one would have overwritten the correct state, leaving wrong diagnostic offsets and a stale preview until the next edit.Fix:
refresh()'s view-sending tail becomesrenderViews(uri, state), a pure output of the cached state. A setting change calls it synchronously for each open document: nothing is parsed, compiled, or stored, so there is nothing to race with. The preview then shows the last compiled text at the new schedule, and the pending edit's refresh replaces it as before.Checked with the driver (4 timings, final preview always the new text) and the audit's startup script (A3 still follows the setting). No unit test: server.ts wires a live connection; an end-to-end test is part of the missing tests in audit B11. No changeset: the setting and its refresh are new in 1.4.0.