terminal: Check for script existence properly before activating it (#23476)

Piotr Osiewicz created

We were not covering a variant where the returned metadata was Ok(None)

Closes #ISSUE

Release Notes:

- Fixed venv activation script path showing up in terminal for
non-existant scripts.

Change summary

crates/project/src/terminals.rs | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

Detailed changes

crates/project/src/terminals.rs 🔗

@@ -490,9 +490,10 @@ impl Project {
             "windows" => "\r",
             _ => "\n",
         };
-        if smol::block_on(self.fs.metadata(path.as_ref())).is_err() {
-            return None;
-        }
+        smol::block_on(self.fs.metadata(path.as_ref()))
+            .ok()
+            .flatten()?;
+
         Some(format!(
             "{} {} ; clear{}",
             activate_keyword, quoted, line_ending