Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Highlighted occurrences do not show in scroll bar when gopls is enabled #2664

Closed
bconway opened this issue Jul 19, 2019 · 11 comments · Fixed by #2833
Closed

Highlighted occurrences do not show in scroll bar when gopls is enabled #2664

bconway opened this issue Jul 19, 2019 · 11 comments · Fixed by #2833

Comments

@bconway
Copy link

bconway commented Jul 19, 2019

Latest stable vscode-go on macOS Mojave.

$ gopls version
version v0.1.3-cmd.gopls, built in $GOPATH mode

When gopls is enabled, highlighted words no longer show in the scroll bar. This happens regardless of editor.occurrencesHighlight setting (which I prefer false, but tested in both configurations).

This does not affect other non-Go file formats, like settings.json.

No language server:
No language server

Gopls:
gopls

Thanks.

@ramya-rao-a
Copy link
Contributor

This is interesting... I see this too, but as far as I know this feature is language agnostic and VS Code shouldn't be caring about whether a language server is being used or not to provide this feature...

@rebornix Any idea why this might be happening or how a language server can possibly interfere with this feature?

@rebornix
Copy link
Member

I'm wondering whether it's because of DocumentHighlightProvider.provideDocumentHighlights which might change the behavior of word highlight features.

@ramya-rao-a
Copy link
Contributor

@rebornix Thanks! I can confirm that the language server does register a document highlight provider.

So it looks like VS Code highlights all occurrences of the word by default unless a document highlight provider is registered. As per https://microsoft.github.io/language-server-protocol/specification#textDocument_documentHighlight, a document highlight provider is very similar to reference provider, which explains why the results from the language server is a much smaller subset than the textual occurrences.

@rebornix So am guessing this is an expected behavior?

@rebornix
Copy link
Member

@ramya-rao-a yup, it's as expected.

@ramya-rao-a
Copy link
Contributor

Thanks @rebornix

Closing this issue as this is the expected behavior

@bconway
Copy link
Author

bconway commented Aug 1, 2019

@ramya-rao-a Can this be kept open until there is feature parity in this regard with and without the language server? Not being able to skim highlighted occurrences in the scroll bar is a big usability regression for me. I can't imagine I'm the only one.

@stamblerre
Copy link
Contributor

@blocknonip: What is your preferred outcome for the resolution of this issue? Is it helpful to you for gopls to highlight all instances of the func keyword? I'd like to understand the expected use cases before gopls adds support for this behavior.

@bconway
Copy link
Author

bconway commented Aug 2, 2019

@stamblerre: I would like it to work in the same fashion that it does without gopls in use. In my particular case ("editor.occurrencesHighlight":false), that would highlight all occurrences in a semantic-insensitive way. For most people, presumably, who don't change that option from the default, it would highlight semantic symbol occurrences.

Basically, I am accustomed to it working in the current way without gopls in use, and I would expect/request that it continue working that way.

@stamblerre
Copy link
Contributor

In this case, I think perhaps VSCode-Go could consider adding a configuration to disable highlighting via gopls, as I don't think it would make sense for gopls to support semantic-insensitive highlighting. @ramya-rao-a: What do you think?

@vscodebot vscodebot bot locked and limited conversation to collaborators Sep 15, 2019
@ramya-rao-a ramya-rao-a reopened this Sep 25, 2019
@ramya-rao-a
Copy link
Contributor

@stamblerre Yes that is a sensible solution.

PRs are welcome to update go.languageServerExperimentalFeatures to include highlight as a property that the user can enable/disable

Code Pointers:

  • Set up local dev environment
  • package.json is the file to edit to update the go.languageServerExperimentalFeatures setting
  • registerLanguageFeatures function in goLanguageServer.ts should be updated to respect the new setting and disable the feature from the language server appropriately

@ramya-rao-a
Copy link
Contributor

Please try the latest beta version of this extension has the fix for this

You can use the go.languageServerExperimentalFeatures setting to disable the "highlight" feature when using the language server

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants