Skip to content

Commit

Permalink
Adds lastKnown cmd to projectError. Adds orc back (#243)
Browse files Browse the repository at this point in the history
* Adds lastKnown cmd to projectError. Adds orc back

* add missing file
  • Loading branch information
jmgomez authored Sep 23, 2024
1 parent c17fb97 commit db2c84d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 0 additions & 2 deletions config.nims
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

# begin Nimble config (version 2)
--noNimblePath
when withDir(thisDir(), system.fileExists("nimble.paths")):
include "nimble.paths"
# end Nimble config

--mm:refc
12 changes: 8 additions & 4 deletions ls.nim
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ proc toPendingRequestStatus(pr: PendingRequest): PendingRequestStatus =
result.state = $pr.state

proc getLspStatus*(ls: LanguageServer): NimLangServerStatus {.raises: [].} =
result.lspPath = getAppFilename()
result.version = LSPVersion
result.extensionCapabilities = ls.extensionCapabilities.toSeq
for project in ls.projectFiles.values:
Expand Down Expand Up @@ -672,10 +673,13 @@ proc onErrorCallback(args: (LanguageServer, string), project: Project) =
error "An error has ocurred while handling nimsuggest err", msg = ex.msg
writeStacktrace(ex)
finally:
ls.projectErrors.add ProjectError(
projectFile: project.file, errorMessage: project.errorMessage
)
ls.sendStatusChanged()
if project.file != "":
ls.projectErrors.add ProjectError(
projectFile: project.file,
errorMessage: project.errorMessage,
lastKnownCmd: project.lastCmd
)
ls.sendStatusChanged()

proc createOrRestartNimsuggest*(
ls: LanguageServer, projectFile: string, uri = ""
Expand Down
4 changes: 3 additions & 1 deletion protocol/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1005,9 +1005,11 @@ type

ProjectError* = object
projectFile*: string
errorMessage*: string #last known cmd? last know request?
errorMessage*: string
lastKnownCmd*: string

NimLangServerStatus* = object
lspPath*: string
version*: string
nimsuggestInstances*: seq[NimSuggestStatus]
openFiles*: seq[string]
Expand Down
4 changes: 3 additions & 1 deletion suggestapi.nim
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ type
errorCallback*: ProjectCallback
errorMessage*: string
failed*: bool
lastCmd*: string

func canHandleUnknown*(ns: Nimsuggest): bool =
nsUnknownFile in ns.capabilities
Expand Down Expand Up @@ -298,7 +299,7 @@ proc getNimsuggestCapabilities*(nimsuggestPath: string):
proc logNsError(project: Project) {.async.} =
let err = string.fromBytes(project.process.stderrStream.read().await)
error "NimSuggest Error (stderr)", err = err
project.markFailed(err) #TODO Error handling should be at the project level
project.markFailed(err)

proc createNimsuggest*(root: string,
nimsuggestPath: string,
Expand Down Expand Up @@ -367,6 +368,7 @@ proc processQueue(self: Nimsuggest): Future[void] {.async.}=
debug "processQueue", size = self.requestQueue.len
while self.requestQueue.len != 0:
let req = self.requestQueue.popFirst
self.project.lastCmd = req.commandString
logScope:
command = req.commandString
if req.future.finished:
Expand Down

0 comments on commit db2c84d

Please sign in to comment.