jeapostrophe / racket-langserver

Other
269 stars 24 forks source link

Exception thrown on empty racket files #30

Closed joebobmiles closed 3 years ago

joebobmiles commented 3 years ago

This seems to be related to #12. I just installed Racket 8.0 and racket-langserver on Windows 10 for use with VSCode and the Magic Racket extension. The instant I opened an empty .rkt file, racket-langserver threw the following error:

Caught exn in request "textDocument/documentHighlight"
hash-ref: no value found for key
  key: 'file:///c:/Users/user/Documents/Programming/hello-racket/hello.rkt
  context...:
   C:\Users\user\AppData\Roaming\Racket\8.0\pkgs\racket-langserver\text-document.rkt:207:0: get-doc-refs
   C:\Users\user\AppData\Roaming\Racket\8.0\pkgs\racket-langserver\text-document.rkt:191:0: document-highlight
   C:\Program Files\Racket\collects\racket\contract\private\arrow-val-first.rkt:486:18
   C:\Users\user\AppData\Roaming\Racket\8.0\pkgs\racket-langserver\methods.rkt:26:0: process-message
   C:\Program Files\Racket\collects\racket\contract\private\arrow-val-first.rkt:486:18
   C:\Users\user\AppData\Roaming\Racket\8.0\pkgs\racket-langserver\main.rkt:54:2: consume

[Error - 7:45:07 PM] Request textDocument/documentHighlight failed.
  Message: internal error in method "textDocument/documentHighlight"
  Code: -32603

My best guess is that the key format 'file:///c:/...' is causing the problem, specifically the third slash following 'file.'

jeapostrophe commented 3 years ago

I have two hypotheses:

  1. That VSCode sent the textDocument/documentHighlight request before the textDocument/didOpen request

  2. That it did send the didOpen, but there is some small difference in the case/etc of the file path that causes the two database entries in the langserver to not match.

Does VSCode let you see a log of its interaction with the server? (Perhaps in the same place you saw this error?) If so, you could add in between these two lines (https://github.com/jeapostrophe/racket-langserver/blob/master/methods.rkt#L26-L27) (eprintf "~s" msg) and see what it says