diff --git a/ls.nim b/ls.nim index 2d67e1d..72249de 100644 --- a/ls.nim +++ b/ls.nim @@ -175,6 +175,7 @@ type failTable*: Table[string, int] #Project file to fail count #List of errors (crashes) nimsuggest has had since the lsp session started + checkInProgress*: bool Certainty* = enum None @@ -900,6 +901,11 @@ proc tryGetNimsuggest*( return none(NimSuggest) proc checkProject*(ls: LanguageServer, uri: string): Future[void] {.async, gcsafe.} = + if ls.checkInProgress: + return + ls.checkInProgress = true + defer: ls.checkInProgress = false + if not ls.getWorkspaceConfiguration.await().autoCheckProject.get(true): return let conf = await ls.getAndWaitForWorkspaceConfiguration() @@ -953,6 +959,10 @@ proc checkProject*(ls: LanguageServer, uri: string): Future[void] {.async, gcsaf ls.workDoneProgressCreate(token) ls.progress(token, "begin", fmt "Checking project {uri.uriToPath}") nimsuggest.checkProjectInProgress = true + defer: + nimsuggest.checkProjectInProgress = false + ls.progress(token, "end") + proc getFilepath(s: Suggest): string = s.filepath @@ -976,7 +986,6 @@ proc checkProject*(ls: LanguageServer, uri: string): Future[void] {.async, gcsaf PublishDiagnosticsParams %* {"uri": pathToUri(path), "diagnostics": @[]} ls.notify("textDocument/publishDiagnostics", %params) ls.filesWithDiags = filesWithDiags - nimsuggest.checkProjectInProgress = false if nimsuggest.needsCheckProject: nimsuggest.needsCheckProject = false diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..ee4cf1e --- /dev/null +++ b/test.txt @@ -0,0 +1,9 @@ +Content-Length: 256 + +{"jsonrpc":"2.0","method":"extension/statusUpdate","params":{"lspPath":"/Volumes/Store/langserver/nimlangserver","version":"1.6.0","nimsuggestInstances":[],"openFiles":[],"extensionCapabilities":["RestartSuggest"],"pendingRequests":[],"projectErrors":[]}} +Content-Length: 256 + +{"jsonrpc":"2.0","method":"extension/statusUpdate","params":{"lspPath":"/Volumes/Store/langserver/nimlangserver","version":"1.6.0","nimsuggestInstances":[],"openFiles":[],"extensionCapabilities":["RestartSuggest"],"pendingRequests":[],"projectErrors":[]}} +Content-Length: 256 + +{"jsonrpc":"2.0","method":"extension/statusUpdate","params":{"lspPath":"/Volumes/Store/langserver/nimlangserver","version":"1.6.0","nimsuggestInstances":[],"openFiles":[],"extensionCapabilities":["RestartSuggest"],"pendingRequests":[],"projectErrors":[]}}