Skip to content

Incorrect highlighting in hover in VS Code #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sheaf opened this issue Sep 9, 2020 · 3 comments
Open

Incorrect highlighting in hover in VS Code #389

sheaf opened this issue Sep 9, 2020 · 3 comments
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@sheaf
Copy link
Contributor

sheaf commented Sep 9, 2020

I have noticed the following issues in hover highlighting in VS Code:

  1. Type highlighted as a value.
    highlight_hover_error_1

  2. Multi-line type signature incorrectly highlighted.
    highlight_hover_error_2

As one of the maintainers of the VS Code syntax highlighting extension I'd like to figure out how to go about fixing these issues.

Could someone let me know how the hover syntax highlighting works in VS Code, i.e. which part of the code is responsible for generating the content of the hover boxes, and in what way is the syntax highlighting engine being called? Then I can try to solve the above two problems. Edit: this appears to be at Development.IDE.Spans.AtPoint.atPoint in ghcide. Going to experiment.

Let me know if you come across any other issues with hover syntax highlighting.

@sheaf
Copy link
Contributor Author

sheaf commented Sep 9, 2020

What I've gleaned so far:

Issue (2) in the OP can readily be fixed by adding extra spaces on the subsequent lines for the type annotation.

For issue (1), I don't know what's best. We could preface the type being hovered over with the text type , which would fix the highlighting but might confuse users, making them think it's a type declaration. We could preface the type with the appropriate declaration (e.g. type , type family , data , data instance , newtype , newtype instance , class ) which seems like a nice idea except I'm not sure what to do for type variables (possibly nothing, not too problematic). Note that currently hovering over parenthesised expressions like (F a b) doesn't create a hover popup, so we don't have to worry about the TyConApp case. We could also preface the type with _ ::, but that doesn't seem very clear to me either.

@jneira jneira added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. component: ghcide labels Sep 10, 2020
@ndmitchell
Copy link
Collaborator

Thanks for getting in touch @sheaf - great to have a line of communication with you!

For (2) I would have thought the pretty printing has prefix spaces in it. So are we losing them? That's a definite bug and it would be great to fix.

For (1) prefixing with type regardless seems grim and confusing. Prefixing with type, type family get seems like useful context, so that seems like a good idea Would also be good to include any type arguments, e.g. data Maybe a. Type variables are a bit of a pain, but also there's no additional context to be had, so I'm not too upset if the highlighting isn't perfect there.

I think we will have expressions eventually, but not for a while, so I'd not worry about it until then.

@Anton-Latukha
Copy link
Collaborator

Anton-Latukha commented Dec 21, 2021

Would work on it soon through #2348 work. To be able to show documentation of arguments - would need to layout arguments first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

4 participants