You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Go-to-def, go-to-declaration stop working after the first time going to the file of interest.
How to reproduce:
open src/import.ml in vscode_ocaml_platform project.
trigger go-to-def on Ocaml_version module name line 210. This opens .../ocaml_version.ml
switch back to file src/import.ml
trigger again go-to-def on Ocaml_version → locate fails with message “not in environment: Ocaml_version”
Interesting observations:
I thought whether opening ocaml_version.ml is causing this problem, so I put code in ocaml_lsp_server.ml (ocaml-lsp project) that would ignore the notification textDocument/didOpen if the file name is ocaml_version.ml . Indeed! After adding this code, I don’t observe this problem, so opening the file must be causing the problem.
either olsp opens a file and that triggers some problem in environments
or merlin is getting incorrect environment when a file is opened
is the first place that’s causing the error. Env_lookup.in_namespaces nss ident env returns None. The function that it invokes is Env.find_module_by_name that uses Location.(!input_name) that's equal to import.ml on the first run of go-to-def and ocaml_version.ml on the second run. Changing it on Query_commands.dispatch as such Location.(input_name := (Mpipeline.final_config pipeline).Mconfig.query.filename); before the main pattern match doesn't help.
Invoking go-to-def on some other symbol in import.ml and coming back to Ocaml_version symbol and then doing go-to-def seems to fix it.
I would guess a configuration issue ?
Maybe OCaml-LSP doesn't refresh the configuration when coming back to the initial file ?
(I will try to reproduce when I find some time.)
CHANGES:
## Fixes
- Fix random requests failing after switching documents (ocaml/ocaml-lsp#904, fixesocaml/ocaml-lsp#898)
- Do not offer related diagnostic information unless the user enables in client
capabilities (ocaml/ocaml-lsp#905)
- Do not offer diagnostic tags unless the client supports them (ocaml/ocaml-lsp#909)
- Do not attach extra data to diagnostics unless the client supports this
(ocaml/ocaml-lsp#910)
- Use /bin/sh instead of /bin/bash. This fixes ocamllsp on NixOS
Problem
Go-to-def, go-to-declaration stop working after the first time going to the file of interest.
How to reproduce:
src/import.ml
in vscode_ocaml_platform project.Ocaml_version
module name line 210. This opens.../ocaml_version.ml
src/import.ml
Ocaml_version
→ locate fails with message “not in environment: Ocaml_version”Interesting observations:
I thought whether opening
ocaml_version.ml
is causing this problem, so I put code inocaml_lsp_server.ml
(ocaml-lsp project) that would ignore the notificationtextDocument/didOpen
if the file name isocaml_version.ml
. Indeed! After adding this code, I don’t observe this problem, so opening the file must be causing the problem.ocaml-lsp/ocaml-lsp-server/vendor/merlin/src/analysis/locate.ml
Line 765 in 2cca06f
Env_lookup.in_namespaces nss ident env
returnsNone
. The function that it invokes isEnv.find_module_by_name
that usesLocation.(!input_name)
that's equal toimport.ml
on the first run of go-to-def andocaml_version.ml
on the second run. Changing it onQuery_commands.dispatch
as suchLocation.(input_name := (Mpipeline.final_config pipeline).Mconfig.query.filename);
before the main pattern match doesn't help.Invoking go-to-def on some other symbol in
import.ml
and coming back toOcaml_version
symbol and then doing go-to-def seems to fix it.Something similar was reported here before - ocamllabs/vscode-ocaml-platform#970
The error message isn't exactly the same however
The text was updated successfully, but these errors were encountered: