From 67a0e4c06eb3914b353f5b8372b944bd536fd0cf Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Thu, 22 Jan 2026 08:25:36 +0100 Subject: [PATCH] add support for link path types --- coman/src/cli/app.rs | 14 +++++++------- coman/src/components/file_tree.rs | 1 + coman/src/cscs/api_client/types.rs | 2 ++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/coman/src/cli/app.rs b/coman/src/cli/app.rs index eeba774..788e4ce 100644 --- a/coman/src/cli/app.rs +++ b/coman/src/cli/app.rs @@ -414,13 +414,13 @@ fn remote_path_completer(current: &std::ffi::OsStr) -> Vec let roots = cscs_file_list(current.clone(), None, None).await; if let Ok(roots) = roots { for root in roots { - if root.path_type == PathType::File { - send.send(CompletionCandidate::new(current.join(root.name.clone()))) - .unwrap(); - } else { + if root.path_type == PathType::Directory { // joining with "" ensures trailing slash send.send(CompletionCandidate::new(current.join(root.name.clone()).join(""))) .unwrap(); + } else { + send.send(CompletionCandidate::new(current.join(root.name.clone()))) + .unwrap(); } } } else { @@ -430,12 +430,12 @@ fn remote_path_completer(current: &std::ffi::OsStr) -> Vec let partial = current.file_name().unwrap().to_string_lossy().into_owned(); for root in roots { if root.name.starts_with(&partial) { - if root.path_type == PathType::File { - send.send(CompletionCandidate::new(parent.join(root.name))).unwrap(); - } else { + if root.path_type == PathType::Directory { // joining with "" ensures trailing slash send.send(CompletionCandidate::new(parent.join(root.name.clone()).join(""))) .unwrap(); + } else { + send.send(CompletionCandidate::new(parent.join(root.name))).unwrap(); } } } diff --git a/coman/src/components/file_tree.rs b/coman/src/components/file_tree.rs index 91bb02c..e578e4d 100644 --- a/coman/src/components/file_tree.rs +++ b/coman/src/components/file_tree.rs @@ -127,6 +127,7 @@ impl Component for FileTree { } } PathType::File => CmdResult::None, + PathType::Link => CmdResult::None, } } Event::Keyboard(KeyEvent { diff --git a/coman/src/cscs/api_client/types.rs b/coman/src/cscs/api_client/types.rs index 0d7a343..234347d 100644 --- a/coman/src/cscs/api_client/types.rs +++ b/coman/src/cscs/api_client/types.rs @@ -78,6 +78,7 @@ impl From for FileSystem { pub enum PathType { Directory, File, + Link, } #[derive(Debug, Eq, Clone, PartialEq, PartialOrd, Ord, tabled::Tabled)] @@ -113,6 +114,7 @@ impl From for PathEntry { path_type: match value.r#type.as_str() { "d" => PathType::Directory, "-" => PathType::File, + "l" => PathType::Link, _ => panic!("Unknown file type: {}", value.r#type), }, permissions: Some(value.permissions),