Skip to content

Add a way to manually update SyntaxHighlighter's highlighting without relying on lines_edited_from() #12503

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
mouzedrift opened this issue May 27, 2025 · 0 comments

Comments

@mouzedrift
Copy link

Describe the project you are working on

I'm implementing a C++ code editor in my app in combination with the LSP to support proper C++ syntax highlighting, but I cannot find a way to implement this asynchronously by subclassing SyntaxHighlighter using the current methods/properties in godot 4.4 mono.

Describe the problem or limitation you are having in your project

The problem I have is that the only way I can get _get_line_syntax_highlighting to be called after calling clear_highlighting_cache or update_cache is by waiting for the lines_edited_from signal. This works if everything runs synchronously, but I'm trying to await the semantic tokens, and this makes the SyntaxHighlighter cache old/cleared data. From what I've observed, TextEdit only seems to update the text colors when you make changes to the text.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

A way to manually trigger _get_line_syntax_highlighting from the subclass to update the syntax highlighting without relying on TextEdit text changes.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Not really sure what the best approach would be, but having a method to make the SyntaxHighlighter manually call _get_line_syntax_highlighting to update the cache could be useful, or perhaps update_cache could do that as well.

If this enhancement will not be used often, can it be worked around with a few lines of script?

A small workaround I found is setting the syntax_highlighter property to null and then reassigning it again, but it makes the text flicker, and that's not very nice to look at.

Is there a reason why this should be core and not an add-on in the asset library?

This seems like a must have.

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

No branches or pull requests

2 participants