Skip to content

Commit

Permalink
* kill child nimsuggest processes also in case of an 'exit' request w…
Browse files Browse the repository at this point in the history
…ithout a prior 'shutdown' request (#147)
  • Loading branch information
nickysn authored Jan 28, 2024
1 parent 4979bb0 commit c369c2b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions nimlangserver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1086,11 +1086,16 @@ proc shutdown(ls: LanguageServer, input: JsonNode): Future[RpcResult] {.async, g
)
trace "Shutdown complete"

proc exit(pipeInput: AsyncInputStream, _: JsonNode):
proc exit(p: tuple[ls: LanguageServer, pipeInput: AsyncInputStream], _: JsonNode):
Future[RpcResult] {.async, gcsafe, raises: [Defect, CatchableError, Exception].} =
if not p.ls.isShutdown:
debug "Received an exit request without prior shutdown request"
for ns in p.ls.projectFiles.values:
let ns = await ns
ns.stop()
debug "Quitting process"
result = none[StringOfJson]()
pipeInput.close()
p.pipeInput.close()

proc didChangeConfiguration(ls: LanguageServer, conf: JsonNode):
Future[void] {.async, gcsafe.} =
Expand Down Expand Up @@ -1131,7 +1136,7 @@ proc registerHandlers*(connection: StreamConnection,
connection.register("textDocument/documentHighlight", partial(documentHighlight, ls))
connection.register("extension/macroExpand", partial(expand, ls))
connection.register("shutdown", partial(shutdown, ls))
connection.register("exit", partial(exit, pipeInput))
connection.register("exit", partial(exit, (ls: ls, pipeInput: pipeInput)))

connection.registerNotification("$/cancelRequest", partial(cancelRequest, ls))
connection.registerNotification("initialized", partial(initialized, ls))
Expand Down

0 comments on commit c369c2b

Please sign in to comment.