-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Editor decoration with mtk
inlineClassName
#1070
Comments
IMHO the whole approach of using decorations for this feature isn't ideal:
I think a cleaner approach would be to update the line tokens themselves after the semantic highlighting comes back. |
Thanks for the feedback, @mofux!
I was not aware of this.
👍 |
@mofux, this raises a question; if two separate rules highlight the same document range, how can this be done by modifying the line tokens only. For instance, a field has to be highlighted as italic (because it is a static Java field) and also has to be colored differently (because it is a deprecated Java field) then how one can get the "combined" metadata for the two separate TM scopes? It is feasible with the |
@kittaakos Their decoration is also not drawn in the minimap, but they don't seem to care 😁 My initial thought was to provide an extra Textmate token that describes the semantic state, like |
This is not an option. That would mean, each time, one adds support for a new language server (LS) in the application, the theme files have to be adjusted with the styles supported by the LS. (Let me know if this need additional clarification.)
This. Cool, you have already answered my next question. Then my plan is the following, what do you think, could this work?
Thank you! |
@kittaakos Yes I guess your approach would work. I've studied the docs in microsoft/vscode-languageserver-node#367 trying to understand how your semantic highlighting is working. From what I understand, semantic tokens identified by the language server can only I'm a little bit confused about the the usage of the term What I'm trying to understand is how for example the TypeScript LS would provide the highlight for an unused variable, which you'll want to fade-out in the editor (just like VSCode does). |
👍
Correct. The LS can only add styles, but the additional styles must overrule (extend) the styles from TM.
{
scope: ["storage.modifier.static.java", "storage.modifier.final.java", "variable.other.definition.java", "meta.definition.variable.java", "meta.class.body.java", "meta.class.java", "source.java"]
} but it is sent as:
The client code resolves the |
Got it. Guess the approach of creating your own class names that take precedence over the build-in |
No no, thank you! I would like to leave the issue open and ask for assistance if required. Once I am ready with the reference implementation, I am happy to link it here and will close the issue. |
Note that vscode-cquery (and soon clangd-vscode) have semantic highlighting implementations that don't appear to suffer from this problem. The API they use to set highlightings is |
I am going to close this as it is fixed in Theia. The credit goes to @HighCommander4. 👍 |
Hi There,
In Eclipse Theia, we are trying to support language server (LS)-based semantic highlighting with editor decorations.
How does it work now:
textDocument/didOpen
andtextDocument/didChange
, the LS calculates the highlighted positions and sends the data back to the client.TokenTheme
.inlineClassName
via thegetClassNameFromMetadata
function. This will result in anmtk${NUMBER}
string.{ inlineClassName }
.It works perfectly unless the on the fly generated
inlineClassName
for the semantic highlighting has a higher number than theinlineClassName
for the TM tokenizer.Problem:
This Monaco Playground Example shows that the editor decoration has limitations if one tries to reuse the
mtk
inline CSS class names. The trailing${NUMBER}
does matter in the class name.Question:
Is it possible to overcome this limitation? I have looked into the code a bit, and it seems, the
_applyInlineDecorations
function is responsible for merging the inline decorations with the tokens line by line. Is it possible to customize it via a custom service? If no, what would be the recommended way to prefer the inline decoration over the tokens?Thank you!
The text was updated successfully, but these errors were encountered: