ocaml-lsp
ocaml-lsp copied to clipboard
documentHighlight works weird
For the demo below when I pu cursor somewhere inside [%expr ....] LSP gives weird highlighting both in QtCreator and VsCode. We have the following log file. There are a lot of duplicate hightlighting ranges there. At least we should remove duplicates from there before sending to client.


open Ppxlib
let loc = Location.none
let wrap_qml _ x = x
let%test _ =
wrap_qml [%expr qml singleton ~name:"asdf" ]
true
let%test _ =
wrap_qml [%expr qml singleton]
true
let%test _ =
wrap_qml
[%expr qml singleton
((author: string) Read getAuthor Write setAuthor Notify authorChanged)
((author: string) Read getAuthor Write setAuthor Notify authorChanged)
]
true
It seems that it is related not only to anti quotations (cursor is on line 67)

In two years this issue has become less annoying. But it still present when my own syntax extension is used. I'm not sure, is it an issue with ocaml-lsp-server or with my extension. I created a demo to demostrate this. https://github.com/Kakadu/ocaml-lps-demo-issue147
Could anybody look again and try to locate where the issue is?

Folks from https://discuss.ocaml.org/t/highlighting-issue-in-ocaml-lsp-server/9858 say that it may be related to the merlin itself. I have no idea how to check that in the merlin (Don't know any editor with both plain merlin and mouse hover support).
@voodoos Do you think that it is merlin-related? Or whom should I ping?
You can look at merlin tests to see how to run an occurrences query on merlin, e.g., ocamlmerlin single occurrences -identifier-at 1:11 -filename ./basic.ml < ./basic.ml. See this https://github.com/ocaml/merlin/tree/master/tests/test-dirs/occurrences
I don't remember, however, how to make sure merlin takes into account build info, e.g., ppx rewriters
Sorry for incoherent help. I can have a look next week I think
@voodoos Do you think that it is merlin-related? Or whom should I ping?
It might be related to Merlin, or to the PPX that reports bad location. The first step would be to have a minimal example that could be added to Merlin testsuite. If would be great if you could take the time to prepare one. What we need is:
- a repository with a very simple dune-based project
- the simplest custom ppx possible
- a module (like an executable) using that ppx and where highlighting is broken.
Once you can notice the issue in vscode you can send me the project and give me the precise line/column where the bad selection happen. That would be very helpful!
If would be great if you could take the time to prepare one.
@voodoos, I created PR https://github.com/ocaml/merlin/pull/1469
Closing this issue since it is due to wrong locations in the PPX and not an ocaml-lsp/merlin issue.