ocaml-lsp icon indicating copy to clipboard operation
ocaml-lsp copied to clipboard

documentHighlight works weird

Open Kakadu opened this issue 5 years ago • 6 comments

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.

qtc-hightlight

code-hightlight

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

Kakadu avatar Apr 08 '20 15:04 Kakadu

It seems that it is related not only to anti quotations (cursor is on line 67)

qtc-hightlight2

Kakadu avatar Apr 09 '20 11:04 Kakadu

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?

image

Kakadu avatar May 06 '22 17:05 Kakadu

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?

Kakadu avatar May 17 '22 16:05 Kakadu

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

ulugbekna avatar May 17 '22 16:05 ulugbekna

@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!

voodoos avatar May 18 '22 08:05 voodoos

If would be great if you could take the time to prepare one.

@voodoos, I created PR https://github.com/ocaml/merlin/pull/1469

Kakadu avatar May 19 '22 08:05 Kakadu

Closing this issue since it is due to wrong locations in the PPX and not an ocaml-lsp/merlin issue.

voodoos avatar Oct 25 '22 08:10 voodoos