Use fs to determine if file path is a dir

Kirill Bulatov created

Change summary

crates/terminal_view/src/terminal_view.rs | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

Detailed changes

crates/terminal_view/src/terminal_view.rs 🔗

@@ -193,10 +193,18 @@ impl TerminalView {
                     }
                     let potential_abs_paths = possible_open_targets(&workspace, maybe_path, cx);
                     if let Some(path) = potential_abs_paths.into_iter().next() {
-                        // TODO kb wrong lib call
-                        let is_dir = path.path_like.is_dir();
                         let task_workspace = workspace.clone();
                         cx.spawn(|_, mut cx| async move {
+                            let fs = task_workspace.update(&mut cx, |workspace, cx| {
+                                workspace.project().read(cx).fs().clone()
+                            })?;
+                            let is_dir = fs
+                                .metadata(&path.path_like)
+                                .await?
+                                .with_context(|| {
+                                    format!("Missing metadata for file {:?}", path.path_like)
+                                })?
+                                .is_dir;
                             let opened_items = task_workspace
                                 .update(&mut cx, |workspace, cx| {
                                     workspace.open_paths(