input: trigger pending re-highlight when switching editor language - #2994
Merged
huacnlee merged 1 commit intoSep 7, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2970
Description
set_highlighter()clears the cached highlighter when switching languages, but does not set the internal_pending_updateflag. This means the next render never callsupdate_highlighter(), so the editor stays without syntax highlighting until the user edits the text (which triggersupdate_highlighter(force: true)).The fix replaces
cx.notify()withself.refresh(cx)— a method that already exists for exactly this purpose and sets_pending_update = truebefore notifying.Screenshot
N/A — behavioral fix, no visual change unless highlighting was broken.
Break Changes
None.
How to Test
cargo run -p example-editorin the gpui-kit repo.rsfile (Rust highlighting appears).jsonfile — highlighting should switch to JSON immediately.htmlfile — highlighting should switch to HTML immediatelyWhy the example-editor appeared to work without this fix
The example-editor calls
set_value()afterset_highlighter().set_valueinternally sets_pending_update = true(viareset_lsp_state()), which accidentally triggers the re-highlight on the next render. This is a workaround, not correct behavior —set_highlighter()should work on its own. Every other caller that usesset_highlighter()without a subsequentset_value()hits this bug.Checklist
cargo runfor story tests related to the changes.