From 2cbb313467743cc78bcd062af355a4cfcce90d67 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 28 Oct 2021 17:12:17 -0700 Subject: [PATCH] Avoid panic when rust language isn't present (project unit tests) --- crates/project/src/lib.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/crates/project/src/lib.rs b/crates/project/src/lib.rs index 552974bc69..458e7bf363 100644 --- a/crates/project/src/lib.rs +++ b/crates/project/src/lib.rs @@ -75,18 +75,11 @@ impl Project { let path = Arc::from(abs_path); let language_server = languages .get_language("Rust") - .unwrap() - .start_server(&path, cx); + .map(|language| language.start_server(&path, cx)); cx.spawn(|this, mut cx| async move { - let worktree = Worktree::open_local( - rpc, - path, - fs, - languages, - language_server.log_err().flatten(), - &mut cx, - ) - .await?; + let language_server = language_server.and_then(|language| language.log_err().flatten()); + let worktree = + Worktree::open_local(rpc, path, fs, languages, language_server, &mut cx).await?; this.update(&mut cx, |this, cx| { this.add_worktree(worktree.clone(), cx); });