LSP: servers that declare full text sync receive incremental didChange
Fresh sends range edits in textDocument/didChange to every language server, including servers that declare textDocumentSync.change = Full. A full-sync server reads the first change's text as the entire document, so after one keystroke it holds only the typed fragment.
What happens
With harper-ls as the server for Markdown or LaTeX:
- Open a file with a few spelling mistakes. Harper's diagnostics appear.
- Type one character anywhere.
- The diagnostics disappear and stay gone until the file is closed and reopened.
Observed on Fresh 0.5.1 (Termux, Android, aarch64) with harper-ls 2.11.0, configured like this:
"markdown": [
{ "command": "harper-ls", "name": "harper", "args": ["--stdio"], "auto_start": true }
]harper-ls declares full sync. This is its reply to initialize:
"textDocumentSync": { "change": 1, "openClose": true, "save": true }Why
The spec says a server with TextDocumentSyncKind.Full expects "the full content of the document" on every change, and one with None expects no didChange at all. Fresh never reads the server's textDocumentSync capability. At bb5af78 no crate references text_document_sync or TextDocumentSyncKind. handle_did_change_sequential in services/lsp/async_handler.rs forwards whatever content_changes it is given. sync_policy.rs sends full text only to repair a server that fell out of step, never because the server asked for it.
Suggested fix
After initialize, store the server's sync kind. textDocumentSync is either a bare kind or an options object with a change field. Then, per server:
Incremental: send the range edits, as now.Full: send one change with norangeand the buffer's whole text.None: send nodidChange.
Workaround
I run harper-ls behind a small stdio proxy. It keeps a copy of each open document, applies Fresh's range edits to it, and forwards one full-text change instead. Diagnostics then survive editing, which also confirms the incremental messages are the cause.
I have not tested 0.5.2, which is not packaged for Termux yet. The code path above is unchanged on master.
Source: sinelaw/fresh