Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
language: Return early if no grammars are added (#48685)
Marco Mihai Condrachef1f8c5523b93
diff --git a/crates/language/src/language_registry.rs b/crates/language/src/language_registry.rsindex 53906ab3bcd..edcf143ccd8 100644--- a/crates/language/src/language_registry.rs+++ b/crates/language/src/language_registry.rs@@ -552,15 +552,16 @@ impl LanguageRegistry {}/// Adds paths to WASM grammar files, which can be loaded if needed.- pub fn register_wasm_grammars(- &self,- grammars: impl IntoIterator<Item = (impl Into<Arc<str>>, PathBuf)>,- ) {+ pub fn register_wasm_grammars(&self, grammars: Vec<(Arc<str>, PathBuf)>) {+ if grammars.is_empty() {+ return;+ }+let mut state = self.state.write();state.grammars.extend(grammars.into_iter()- .map(|(name, path)| (name.into(), AvailableGrammar::Unloaded(path))),+ .map(|(name, path)| (name, AvailableGrammar::Unloaded(path))),);state.version += 1;state.reload_count += 1;