nim-lang / langserver

The Nim language server implementation (based on nimsuggest)
204 stars 31 forks source link

fix crash on empty file #217

Closed Graveflo closed 3 months ago

Graveflo commented 4 months ago

Basically, if you CTRL+A -> Backspace it can crash the lang server. contentChanges[0] expecting there to be at least one character seems to be the culprit. I also re-arranged the imports, but feel free to reject that change. Also, there was a . missing but apparently that doesn't matter.

edit: The changes in the config were steered by me trying to get Kate's settings to transfer. Not sure if I'm doing that right, but that is what I needed to do to get it work.

jmgomez commented 4 months ago

Can you resolve the conflicts? Sorry it took so long

Graveflo commented 3 months ago

drafting this because on master (and with this PR) I am now getting this error using Kate:

Shutting down due to an error: input(1, 0) Error: { expected
Async traceback:
  /home/ryan/Documents/pbuildtmp/langserverworkspace/langserver/nimlangserver.nim(173) nimlangserver
  /home/ryan/Documents/pbuildtmp/langserverworkspace/langserver/nimlangserver.nim(163) main
  /usr/lib/nim/lib/pure/asyncdispatch.nim(2022) waitFor
  /usr/lib/nim/lib/pure/asyncdispatch.nim(1711) poll
  /usr/lib/nim/lib/pure/asyncdispatch.nim(1452) runOnce
  /usr/lib/nim/lib/system/threadimpl.nim(269) processPendingCallbacks
  /usr/lib/nim/lib/pure/asyncmacro.nim(133) start (Async)
  /usr/lib/nim/lib/pure/json.nim(1047) parseJson
  /usr/lib/nim/lib/pure/json.nim(962) parseJson
  /usr/lib/nim/lib/pure/json.nim(927) parseJson
  /usr/lib/nim/lib/pure/parsejson.nim(518) raiseParseErr
Exception message: input(1, 0) Error: { expected
/home/ryan/Documents/pbuildtmp/langserverworkspace/langserver/nimlangserver.nim(173) nimlangserver
/home/ryan/Documents/pbuildtmp/langserverworkspace/langserver/nimlangserver.nim(163) main
/usr/lib/nim/lib/pure/asyncdispatch.nim(2022) waitFor
/usr/lib/nim/lib/pure/asyncdispatch.nim(1711) poll
/usr/lib/nim/lib/pure/asyncdispatch.nim(1452) runOnce
/usr/lib/nim/lib/system/threadimpl.nim(269) processPendingCallbacks
/usr/lib/nim/lib/pure/asyncmacro.nim(133) start (Async)
/usr/lib/nim/lib/pure/json.nim(1047) parseJson
/usr/lib/nim/lib/pure/json.nim(962) parseJson
/usr/lib/nim/lib/pure/json.nim(927) parseJson
/usr/lib/nim/lib/pure/parsejson.nim(518) raiseParseErr
[[reraised from:
/home/ryan/Documents/pbuildtmp/langserverworkspace/langserver/nimlangserver.nim(173) nimlangserver
/home/ryan/Documents/pbuildtmp/langserverworkspace/langserver/nimlangserver.nim(163) main
/usr/lib/nim/lib/pure/asyncdispatch.nim(2022) waitFor
/usr/lib/nim/lib/pure/asyncdispatch.nim(1711) poll
/usr/lib/nim/lib/pure/asyncdispatch.nim(1452) runOnce
/usr/lib/nim/lib/system/threadimpl.nim(269) processPendingCallbacks
/usr/lib/nim/lib/std/typedthreads.nim(287) start (Async)
]]
[[reraised from:
/home/ryan/Documents/pbuildtmp/langserverworkspace/langserver/nimlangserver.nim(173) nimlangserver
/home/ryan/Documents/pbuildtmp/langserverworkspace/langserver/nimlangserver.nim(163) main
/usr/lib/nim/lib/pure/asyncdispatch.nim(2024) waitFor
/usr/lib/nim/lib/pure/asyncfutures.nim(381) read
]]

Looks like something buried in a macro, so I'm having some trouble tracing the issue. Going to have to look at it later.

Graveflo commented 3 months ago

nvm about the above I had my dependencies messed up