rhaiscript / lsp

Language server for Rhai.
Apache License 2.0
43 stars 4 forks source link

Windows-specific problems #59

Closed schungx closed 2 years ago

schungx commented 2 years ago

Right now, if I put the following into static.d.rhai, it won't be allowed:

image

as operators are not allowed as function names in function declarations.

There are two solutions to this:

1) Allow symbols as function names; this is easiest but of course it breaks with "normal" Rhai code, but it shouldn't matter a great deal because they are already different (for example no function body).

fn ==(x: i64, y: i64) -> bool;

2) Use another keyword, for example

op ==(x: i64, y: i64) -> bool;

op x:i64 == y:i64 -> bool;
tamasfe commented 2 years ago

Yeah sorry, I removed it from the examples, the following is syntactically valid in declarations, but are not processed further:

image

tamasfe commented 2 years ago

I forgot to change : to -> to align with the function syntax.

schungx commented 2 years ago

BTW, just found out the following strangeness:

No syntax errors:

image

Just one small syntax error:

image

As you can see, with any syntax error, built-in functions are not recognized.

schungx commented 2 years ago

The parser seems to recover gracefully by parsing the for statement as a new statement, but some internal state is probably thinking it is invalid.

tamasfe commented 2 years ago

I don't think that parse tree looks what it should look like, can you paste the code so I can check it out?

schungx commented 2 years ago

It is for1.rhai in example scripts. I believe you have it in the examples dir.

tamasfe commented 2 years ago

image

Weird, it looks fine to me.

schungx commented 2 years ago

How should I help you track it down?

schungx commented 2 years ago

Hhmmm.... I just quit vscode and opened the file again. This time it is different:

image

Notice that the for keywords is not highlighted as syntax error.

tamasfe commented 2 years ago

Can you check if there is anything in the logs? There should not even be any HIR errors if there are syntax errors.

And there should be syntax errors.

schungx commented 2 years ago

Can you check if there is anything in the logs? There should not even be any HIR errors if there are syntax errors.

I checked. Nothing. Only a whole bunch of lines saying "WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_js/script.rhai"...

tamasfe commented 2 years ago

That might be it, well, at least it is an issue if you don't have a folder opened.

If it's just a single file open in a vscode window, or a file that is not in the opened folder, it's expected, otherwise it's an issue as the document should be part of a workspace. Whether that is a cause of the error behaviour is unclear.

schungx commented 2 years ago

Well, it is one file out of a whole bunch inside the folder, with static.d.rhai being one of them. I see the line saying static.d.rhai being opened. However, print is still redlined until I manually click open static.d.rhai, then the redlines disappear for all the files.

This is the full log:

 INFO registered request handler method="initialize"
 INFO registered request handler method="textDocument/foldingRange"
 INFO registered request handler method="textDocument/declaration"
 INFO registered request handler method="textDocument/definition"
 INFO registered request handler method="textDocument/references"
 INFO registered request handler method="textDocument/documentSymbol"
 INFO registered request handler method="textDocument/hover"
 INFO registered request handler method="textDocument/completion"
 INFO registered request handler method="textDocument/prepareRename"
 INFO registered request handler method="textDocument/rename"
 INFO registered notification handler method="initialized"
 INFO registered notification handler method="textDocument/didOpen"
 INFO registered notification handler method="textDocument/didChange"
 INFO registered notification handler method="textDocument/didSave"
 INFO registered notification handler method="textDocument/didClose"
 INFO registered notification handler method="workspace/didChangeConfiguration"
 INFO registered notification handler method="workspace/didChangeWorkspaceFolders"
 INFO registered notification handler method="workspace/didChangeWatchedFiles"
 INFO registered request handler method="rhai/syntaxTree"
 INFO registered request handler method="rhai/convertOffsets"
 INFO LSP server listening transport="stdio"
 INFO initialized: discovering files root="c:\\Git\\rhai"
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_js/script.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/examples/event_handler_js/script.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_main/script.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/examples/event_handler_main/script.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_map/script.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/examples/event_handler_map/script.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/array.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/array.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/assignment.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/assignment.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/comments.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/comments.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/doc-comments.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/doc-comments.rhai
 WARN no notification handler registered method=$/setTrace
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/fibonacci.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/fibonacci.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/for1.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/for1.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/for2.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/for2.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/for3.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/for3.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl1.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/function_decl1.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl2.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/function_decl2.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl3.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/function_decl3.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl4.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/function_decl4.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/if1.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/if1.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/if2.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/if2.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/loop.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/loop.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/mat_mul.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/mat_mul.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/module.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/module.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/oop.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/oop.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/op1.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/op1.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/op2.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/op2.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/op3.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/op3.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/primes.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/primes.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/speed_test.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/speed_test.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/static.d.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/static.d.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/string.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/string.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/strings_map.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/strings_map.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/switch.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/switch.rhai
 WARN initialized: using detached workspace document_url=file:///c:/Git/rhai/scripts/while.rhai
 INFO initialized: loaded file url=file:///c:/Git/rhai/scripts/while.rhai
 INFO initialized: found files count=31 root="c:\\Git\\rhai"
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_js/script.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_js/script.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_main/script.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_main/script.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_map/script.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/array.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/array.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/assignment.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/assignment.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/comments.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/comments.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/doc-comments.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/doc-comments.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/fibonacci.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/fibonacci.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl4.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl4.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/if1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/if1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/if2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/if2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/loop.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/loop.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/mat_mul.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/mat_mul.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/module.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/module.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/oop.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/oop.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/primes.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/speed_test.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/speed_test.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/static.d.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/static.d.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/string.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/string.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/strings_map.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/strings_map.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/switch.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/switch.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/while.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/while.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_js/script.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_js/script.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_main/script.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_main/script.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_map/script.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/array.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/array.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/assignment.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/assignment.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/comments.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/comments.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/doc-comments.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/doc-comments.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/fibonacci.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/fibonacci.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl4.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl4.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/if1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/if1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/if2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/if2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/loop.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/loop.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/mat_mul.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/mat_mul.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/module.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/module.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/oop.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/oop.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/primes.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/speed_test.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/speed_test.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/static.d.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/static.d.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/string.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/string.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/strings_map.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/strings_map.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/switch.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/switch.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/while.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/while.rhai
 WARN no notification handler registered method=$/setTrace
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_js/script.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_js/script.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_main/script.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_main/script.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/examples/event_handler_map/script.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/array.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/array.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/assignment.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/assignment.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/comments.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/comments.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/doc-comments.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/doc-comments.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/fibonacci.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/fibonacci.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/for3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl4.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/function_decl4.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/if1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/if1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/if2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/if2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/loop.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/loop.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/mat_mul.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/mat_mul.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/module.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/module.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/oop.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/oop.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op1.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op2.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/op3.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/primes.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/speed_test.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/speed_test.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/static.d.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/static.d.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/string.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/string.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/strings_map.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/strings_map.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/switch.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/switch.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/while.rhai
 WARN publish_diagnostics: using detached workspace document_url=file:///c:/Git/rhai/scripts/while.rhai
schungx commented 2 years ago

Clicking on while.rhai does this:

image

Clicking on static.d.rhai once, then open while.rhai again:

image

tamasfe commented 2 years ago

Ah yeah. It's a windows specific issue, we'll have to look into how to handle absolute paths correctly.

On unix-like systems all file paths are quite simple, workspaces look like /some/nested/directory, while the path of a file in that workspace looks like /some/nested/directory/example.rhai, it is trivial to check whether a file is part of a workspace via simply a prefix check.

It is not as simple under windows, because:

We'll probably have to "normalize" windows paths in some way in the LSP to account for these issues.

schungx commented 2 years ago

Ah. So this is a Windows-related issue afterall.

I agree, path processing in Windows is a royal pain. Usually you need to use File::canonicalize to make a canonical pathname - this one works fine, I remember.

Usually what I do is the avoid attaching multi-segment paths at all costs. Only attach each layer one at a time and it usually works fine.

schungx commented 2 years ago

I can see that you have root="c:\\Git\\rhai", meaning that it is using Windows-style paths.

You need to convert it into canonical, then it'll look like file::///c:/Git/rhai and this path is now absolute.

tamasfe commented 2 years ago

Yeah I see it now, that's one problem, I'll open an issue for that separately. Whether that fixes this remains to be seen.

schungx commented 2 years ago

Confirmed that the path issue is resolved.