Avoid an unwrap when loading languages (#8562)

We couldn't reproduce the panic, but I believe it was possible when
uninstalling an extension while one if its grammars was still loading.

Release Notes:
- Fixed a crash that could happen when uninstalling a language extension
while its grammar was loading.

---------

Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
Max Brunsfeld 2024-02-28 14:08:45 -08:00 committed by GitHub
parent 4a4ca2c3b8
commit 9e4b3ce94c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 38 additions and 31 deletions

View file

@ -2751,18 +2751,20 @@ mod tests {
}
#[gpui::test]
fn test_bundled_languages(cx: &mut AppContext) {
let settings = SettingsStore::test(cx);
async fn test_bundled_languages(cx: &mut TestAppContext) {
let settings = cx.update(|cx| SettingsStore::test(cx));
cx.set_global(settings);
let mut languages = LanguageRegistry::test();
languages.set_executor(cx.background_executor().clone());
languages.set_executor(cx.executor().clone());
let languages = Arc::new(languages);
let node_runtime = node_runtime::FakeNodeRuntime::new();
languages::init(languages.clone(), node_runtime, cx);
cx.update(|cx| {
languages::init(languages.clone(), node_runtime, cx);
});
for name in languages.language_names() {
languages.language_for_name(&name);
languages.language_for_name(&name).await.unwrap();
}
cx.background_executor().run_until_parked();
cx.run_until_parked();
}
fn init_test(cx: &mut TestAppContext) -> Arc<AppState> {