Skip to content
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

Error diagnostic highlight doesn't appear with semantic highlighting enabled #1934

Closed
rchl opened this issue Jan 16, 2022 · 5 comments · Fixed by #1969
Closed

Error diagnostic highlight doesn't appear with semantic highlighting enabled #1934

rchl opened this issue Jan 16, 2022 · 5 comments · Fixed by #1969

Comments

@rchl
Copy link
Member

rchl commented Jan 16, 2022

Describe the bug

With LSP-typescript and semantic highlighting enabled, I often notice that the error highlighting don't show up in the document if a token is also highlighted by semantic highlighting.

To Reproduce
Steps to reproduce the behavior:

  1. Check this line with LSP-typescript for example: https://github.com/microsoft/vscode/blob/4be6df74d4ea0c6511c42d5951df0d4f78f1cf83/extensions/typescript-language-features/src/languageFeatures/inlayHints.ts#L72-L72

Screenshots

The hint word is not marked with a squiggly line:

Screenshot 2022-01-16 at 21 52 17

Environment (please complete the following information):

  • OS: macOS
  • Sublime Text version: 4125
  • LSP version: 1.15.0
  • Language servers used: LSP-typescript
@jwortmann
Copy link
Member

I believe that is a consequence from appending the modifier to the semantic token scope in

scope += " meta.semantic-token.{}.{}.lsp".format(token_type.lower(), token_modifiers[0].lower())
(for the purpose of being able to define a color scheme rule for tokens with modifiers). In this case the region key for this token, which is derived from the scope, will be lsp_variable.parameter.lsp meta.semantic-token.parameter.declaration.lsp.

But when we initialize the region keys, we use only the scopes defined in our predefined mapping:

self.view.add_regions("lsp_{} meta.semantic-token.{}.lsp".format(scope, key), r)

For this case we don't have a special scope defined, only for "parameter" token without any modifier:

"parameter": "variable.parameter.lsp",

I'm not sure how this can be solved in a general way, because we don't know beforehand which of the possible combinations of token types & modifiers the server will use. It might work to add all possible combinations of token types & modifiers which were announced by the server, but that would also mean a lot of unnecessary region keys.

As a quick solution, you can explicitly declare this token with a scope in LSP-typescript.sublime-settings, for example

{
    "semantic_tokens": {
        "parameter.declaration": "variable.parameter.lsp"
    }
}

Then the corresponding region key will also be initialized. I've tested it a few times with this adjustment, and it seems to work most of the time - but for some reason still not everytime reliably. Hm, maybe there is still some unknown behavior of the region draw order by ST, that we didn't consider yet.

As a sidenote, I found an unrelated bug that we forgot to lowercase the scope name when initializing the region keys, so the don't necessarily match in a few cases.

@rchl
Copy link
Member Author

rchl commented Jan 16, 2022

Thanks for the explanation.

I would maybe use the workaround for now but I guess the same issue could apply to other types of tokens.

@Penguin98kStudio
Copy link

Penguin98kStudio commented May 9, 2022

image

It seems to me that the region draw always draws the highlight lines first then draws the semantic highlight over it hence the issue,
dun know if its possible to fix their order tho

@Rayzeq
Copy link

Rayzeq commented Sep 11, 2024

It seems that it's still broken, or that there's been a regression.

Screenshots
image

The yellow squiggly line and the blue dotted line should underline modules::*

Environment (please complete the following information)
OS: Linux (nixos)
Sublime Text version: 4169
LSP version: 2.2.0
Language servers used: LSP-rust-analyser

@rchl
Copy link
Member Author

rchl commented Sep 16, 2024

Feel free to create a new issue with reproduction steps.

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

Successfully merging a pull request may close this issue.

4 participants