diff --git a/lapce-app/src/file_explorer/node.rs b/lapce-app/src/file_explorer/node.rs index 633b6596..0f40154b 100644 --- a/lapce-app/src/file_explorer/node.rs +++ b/lapce-app/src/file_explorer/node.rs @@ -17,7 +17,10 @@ pub fn new(file_node_item: FileNodeItem, naming: Naming) -> Self { impl VirtualVector for FileNodeVirtualList { fn total_len(&self) -> usize { - self.file_node_item.children_open_count + if !self.file_node_item.path.exists() { + return 0; + } + self.file_node_item.children_open_count + 1 } fn slice( @@ -27,11 +30,14 @@ fn slice( let naming = &self.naming; let root = &self.file_node_item; + if !root.path.exists() { + return Vec::new().into_iter(); + } let min = range.start; let max = range.end; let mut view_items = Vec::new(); - root.append_children_view_slice(&mut view_items, naming, min, max, 0, 0); + root.append_view_slice(&mut view_items, naming, min, max, 0, 1); view_items.into_iter() } diff --git a/lapce-app/src/file_explorer/view.rs b/lapce-app/src/file_explorer/view.rs index 21e12973..50d6743f 100644 --- a/lapce-app/src/file_explorer/view.rs +++ b/lapce-app/src/file_explorer/view.rs @@ -175,22 +175,56 @@ fn file_node_text_view( let ui_line_height = data.common.ui_line_height; match node.kind.clone() { - FileNodeViewKind::Path(path) => container( - label(move || { - path.file_name() - .map(|f| f.to_string_lossy().to_string()) - .unwrap_or_default() - }) - .style(move |s| { - s.height(ui_line_height.get()) - .color(file_node_text_color( - config, - node.clone(), - source_control.clone(), - )) - .selectable(false) - }), - ), + FileNodeViewKind::Path(path) => { + if node.is_root { + let file = path.clone(); + container(( + label(move || { + file.file_name() + .map(|f| f.to_string_lossy().to_string()) + .unwrap_or_default() + }) + .style(move |s| { + s.height(ui_line_height.get()) + .color(file_node_text_color( + config, + node.clone(), + source_control.clone(), + )) + .padding_right(5.0) + .selectable(false) + }), + label(move || path.to_string_lossy().to_string()).style( + move |s| { + s.height(ui_line_height.get()) + .color( + config + .get() + .color(LapceColor::PANEL_FOREGROUND_DIM), + ) + .selectable(false) + }, + ), + )) + } else { + container( + label(move || { + path.file_name() + .map(|f| f.to_string_lossy().to_string()) + .unwrap_or_default() + }) + .style(move |s| { + s.height(ui_line_height.get()) + .color(file_node_text_color( + config, + node.clone(), + source_control.clone(), + )) + .selectable(false) + }), + ) + } + } FileNodeViewKind::Renaming { path, err } => { if data.naming.with_untracked(Naming::editor_needs_reset) { initialize_naming_editor_with_path(&data, &path); diff --git a/lapce-rpc/src/file.rs b/lapce-rpc/src/file.rs index 3db94531..c2010e38 100644 --- a/lapce-rpc/src/file.rs +++ b/lapce-rpc/src/file.rs @@ -232,6 +232,7 @@ pub fn extra_node( err: n.state.err().map(ToString::to_string), }, is_dir: n.is_dir, + is_root: false, open: false, level: level + 1, }), @@ -241,6 +242,7 @@ pub fn extra_node( err: d.state.err().map(ToString::to_string), }, is_dir, + is_root: false, open: false, level: level + 1, }), @@ -253,6 +255,7 @@ pub fn extra_node( pub struct FileNodeViewData { pub kind: FileNodeViewKind, pub is_dir: bool, + pub is_root: bool, pub open: bool, pub level: usize, } @@ -472,6 +475,7 @@ pub fn append_view_slice( view_items.push(FileNodeViewData { kind, is_dir: self.is_dir, + is_root: level == 1, open: self.open, level, });