Skip to content

Commit

Permalink
feat: Disable push diagnostic when pull is supported by the client
Browse files Browse the repository at this point in the history
  • Loading branch information
razzmatazz committed Jul 3, 2024
1 parent b71265f commit 53e299d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unrelease]
* Implement pull diagnostics for better performance;
- https://github.com/razzmatazz/csharp-language-server/pull/174

## [0.14.0] - 2024-06-23 / Palanga
* Speed up completion by not showing name suggestions or items from unimported namespaces
- https://github.com/razzmatazz/csharp-language-server/pull/168
Expand Down
20 changes: 14 additions & 6 deletions src/CSharpLanguageServer/State/ServerState.fs
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,16 @@ let processServerEvent (logger: ILog) state postSelf msg : Async<ServerState> =
| [] -> (None, [])
| uri :: remainder -> (Some uri, remainder)

match nextDocUri with
| None ->
// backlog is empty, nothing to do
return state

| Some docUri ->
// push diagnostic is enabled only if pull diagnostics is
// not reported to be supported by the client
let diagnosticPullSupported =
state.ClientCapabilities.TextDocument
|> Option.map _.Diagnostic
|> Option.map (fun _ -> true)
|> Option.defaultValue false

match diagnosticPullSupported, nextDocUri with
| false, Some docUri ->
let newState = { state with PushDiagnosticsDocumentBacklog = newBacklog }

let docAndTypeMaybe = docUri |> getDocumentForUriOfType state ServerDocumentType.AnyDocument
Expand Down Expand Up @@ -356,6 +360,10 @@ let processServerEvent (logger: ILog) state postSelf msg : Async<ServerState> =

return newState

| _, _->
// backlog is empty or pull diagnostics is enabled instead,--nothing to do
return state

| PushDiagnosticsDocumentDiagnosticsResolution result ->
// enqueue processing for the next doc on the queue (if any)
postSelf PushDiagnosticsProcessPendingDocuments
Expand Down

0 comments on commit 53e299d

Please sign in to comment.