fix: server: handle requests for closed files
This commit is contained in:
parent
002efd0db6
commit
8a5344ed17
1 changed files with 11 additions and 0 deletions
|
|
@ -379,6 +379,17 @@ section MessageHandling
|
|||
let handle := fun α [FromJson α] [ToJson α] [FileSource α] => do
|
||||
let parsedParams ← parseParams α params
|
||||
let uri := fileSource parsedParams
|
||||
try
|
||||
findFileWorker uri
|
||||
catch _ =>
|
||||
-- VS Code sometimes sends us requests just after closing a file?
|
||||
-- This is permitted by the spec, but seems pointless, and there's not much we can do,
|
||||
-- so we return an error instead.
|
||||
(←read).hOut.writeLspResponseError
|
||||
{ id := id
|
||||
code := ErrorCode.contentModified
|
||||
message := s!"Cannot process request to closed file '{uri}'" }
|
||||
return
|
||||
tryWriteMessage uri ⟨id, method, parsedParams⟩ FileWorker.writeRequest
|
||||
match method with
|
||||
| "textDocument/waitForDiagnostics" => handle WaitForDiagnosticsParams
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue