fix push diagnostics sending outdated diagnostics
This commit is contained in:
parent
eb80380ea7
commit
7036ce5f22
@ -234,9 +234,9 @@ Every time the client sends a message, it gets handled by a function in the corr
|
|||||||
(send (message.diagnostics file))))
|
(send (message.diagnostics file))))
|
||||||
|
|
||||||
(λ notifications.textDocument/didChange [server send {: contentChanges :textDocument {: uri}}]
|
(λ notifications.textDocument/didChange [server send {: contentChanges :textDocument {: uri}}]
|
||||||
(local file (files.get-by-uri server uri))
|
(let [file (files.get-by-uri server uri)
|
||||||
(files.set-uri-contents server uri (utils.apply-changes file.text contentChanges server.position-encoding))
|
file (files.set-uri-contents server uri (utils.apply-changes file.text contentChanges server.position-encoding))]
|
||||||
(push-diagnostics server file send))
|
(push-diagnostics server file send)))
|
||||||
|
|
||||||
(λ notifications.textDocument/didOpen [server send {:textDocument {: text : uri}}]
|
(λ notifications.textDocument/didOpen [server send {:textDocument {: text : uri}}]
|
||||||
(local file (files.set-uri-contents server uri text))
|
(local file (files.set-uri-contents server uri text))
|
||||||
|
|||||||
@ -192,10 +192,28 @@
|
|||||||
[{:message "expected whitespace before token"}]
|
[{:message "expected whitespace before token"}]
|
||||||
[]))
|
[]))
|
||||||
|
|
||||||
|
(fn test-after-edit []
|
||||||
|
(let [{: uri : client : locations}
|
||||||
|
(create-client "(fn abc [] (+ a====))
|
||||||
|
{: abc}"
|
||||||
|
;; wants push notifications
|
||||||
|
{:capabilities {:textDocument {:publishDiagnostics true}}})
|
||||||
|
[{:params {: diagnostics}}] (client:change-text! uri [{:range (. locations 1 :range) :text " b"}])]
|
||||||
|
(faith.= diagnostics [{:code "compiler-error"
|
||||||
|
:message "unknown identifier: a"
|
||||||
|
:range {:end {:character 15 :line 0} :start {:character 14 :line 0}}
|
||||||
|
:severity 1}
|
||||||
|
{:code "compiler-error"
|
||||||
|
:message "unknown identifier: b"
|
||||||
|
:range {:end {:character 17 :line 0} :start {:character 16 :line 0}}
|
||||||
|
:severity 1}])
|
||||||
|
nil))
|
||||||
|
|
||||||
{: test-lua-versions
|
{: test-lua-versions
|
||||||
: test-macro-environment
|
: test-macro-environment
|
||||||
: test-compile-error
|
: test-compile-error
|
||||||
: test-parse-error
|
: test-parse-error
|
||||||
: test-macro-error
|
: test-macro-error
|
||||||
: test-multiple-errors
|
: test-multiple-errors
|
||||||
: test-warnings}
|
: test-warnings
|
||||||
|
: test-after-edit}
|
||||||
|
|||||||
@ -24,6 +24,15 @@
|
|||||||
(fn pretend-this-file-exists! [self name text]
|
(fn pretend-this-file-exists! [self name text]
|
||||||
(tset self.server.preload name text))
|
(tset self.server.preload name text))
|
||||||
|
|
||||||
|
(fn change-text! [self name contentChanges]
|
||||||
|
(dispatch.handle* self.server
|
||||||
|
(message.create-notification :textDocument/didChange
|
||||||
|
{: contentChanges
|
||||||
|
:textDocument
|
||||||
|
{:uri name
|
||||||
|
:languageId "fennel"
|
||||||
|
:version 2}})))
|
||||||
|
|
||||||
(fn completion [self file position]
|
(fn completion [self file position]
|
||||||
(dispatch.handle* self.server
|
(dispatch.handle* self.server
|
||||||
(message.create-request (next-id! self) :textDocument/completion
|
(message.create-request (next-id! self) :textDocument/completion
|
||||||
@ -103,6 +112,7 @@
|
|||||||
|
|
||||||
(local client-mt
|
(local client-mt
|
||||||
{:__index {: open-file!
|
{:__index {: open-file!
|
||||||
|
: change-text!
|
||||||
: pretend-this-file-exists!
|
: pretend-this-file-exists!
|
||||||
: completion
|
: completion
|
||||||
: completion-item-resolve
|
: completion-item-resolve
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user