Skip to content

Commit f1f8c55

Browse files
language: Return early if no grammars are added (#48685)
Helps #48601 Whenever an extension is installed, we call `register_grammars` even when the grammar list is empty. This unnecessarily increments reload_count and notifies the LSP store, which clears all languages and triggers a full reparse. Clearing languages also emits `LanguageChanged` events for buffers, causing the editor to perform expensive recomputations (like #48622) which can block the main thread for large multibuffers. This PR addresses the empty-grammar case. If an extension actually adds a grammar, the underlying issue still exists and will require additional fixes to fully resolve. - [ ] Tests or screenshots needed? - [x] Code Reviewed - [ ] Manual QA Release Notes: - Fixed an issue where installing theme extensions could block the main thread
1 parent 809d545 commit f1f8c55

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

crates/language/src/language_registry.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,15 +552,16 @@ impl LanguageRegistry {
552552
}
553553

554554
/// Adds paths to WASM grammar files, which can be loaded if needed.
555-
pub fn register_wasm_grammars(
556-
&self,
557-
grammars: impl IntoIterator<Item = (impl Into<Arc<str>>, PathBuf)>,
558-
) {
555+
pub fn register_wasm_grammars(&self, grammars: Vec<(Arc<str>, PathBuf)>) {
556+
if grammars.is_empty() {
557+
return;
558+
}
559+
559560
let mut state = self.state.write();
560561
state.grammars.extend(
561562
grammars
562563
.into_iter()
563-
.map(|(name, path)| (name.into(), AvailableGrammar::Unloaded(path))),
564+
.map(|(name, path)| (name, AvailableGrammar::Unloaded(path))),
564565
);
565566
state.version += 1;
566567
state.reload_count += 1;

0 commit comments

Comments
 (0)