diff --git a/gpui/src/elements/container.rs b/gpui/src/elements/container.rs index dd58cf07398ed001f2b05e28c9a7398a4a581c4a..02d4cece951781115ca3820fe258bbfc05e4e747 100644 --- a/gpui/src/elements/container.rs +++ b/gpui/src/elements/container.rs @@ -84,6 +84,11 @@ impl Container { self } + pub fn with_padding_left(mut self, padding: f32) -> Self { + self.style.padding.left = padding; + self + } + pub fn with_padding_right(mut self, padding: f32) -> Self { self.style.padding.right = padding; self diff --git a/zed/assets/themes/_base.toml b/zed/assets/themes/_base.toml index 59c232e992145b5f4cc3f5483925add018d21aa9..8060d5d139abf762d9649f6e05e98d73a4147fcc 100644 --- a/zed/assets/themes/_base.toml +++ b/zed/assets/themes/_base.toml @@ -161,9 +161,16 @@ corner_radius = 6 [project_panel] extends = "$panel" -entry = "$text.0" -padding.left = "$panel.padding" -padding.right = "$panel.padding" +padding = 0 +entry_base_padding = "$panel.padding" + +[project_panel.entry] +extends = "$text.0" +padding = { top = 3, bottom = 3 } + +[project_panel.hovered_entry] +extends = "$project_panel.entry" +background = "$state.hover" [selector] background = "$surface.0" diff --git a/zed/src/project_panel.rs b/zed/src/project_panel.rs index 5866569a4555ad1418b7413db8021d89e2f12206..c86a0927ac479a653e1a71c6aff8cdd11af6b3f7 100644 --- a/zed/src/project_panel.rs +++ b/zed/src/project_panel.rs @@ -2,6 +2,7 @@ use crate::{project::Project, theme, Settings}; use gpui::{ action, elements::{Label, MouseEventHandler, UniformList, UniformListState}, + platform::CursorStyle, Element, ElementBox, Entity, ModelHandle, MutableAppContext, ReadModel, View, ViewContext, WeakViewHandle, }; @@ -165,10 +166,16 @@ impl ProjectPanel { MouseEventHandler::new::( (entry.worktree_ix, entry.entry_id), cx, - |state, cx| { - Label::new(details.filename, theme.entry.clone()) + |state, _| { + let style = if state.hovered { + &theme.hovered_entry + } else { + &theme.entry + }; + Label::new(details.filename, style.text.clone()) .contained() - .with_margin_left(details.depth as f32 * 20.) + .with_style(style.container) + .with_padding_left(theme.entry_base_padding + details.depth as f32 * 20.) .boxed() }, ) @@ -179,6 +186,7 @@ impl ProjectPanel { cx.dispatch_action(Open(entry)) } }) + .with_cursor_style(CursorStyle::PointingHand) .boxed() } } diff --git a/zed/src/theme.rs b/zed/src/theme.rs index a8ef40a37c48c96c8a3a77edffe86f528c949e6f..270925e93b7a458f1f4fa53ed189d328255e145c 100644 --- a/zed/src/theme.rs +++ b/zed/src/theme.rs @@ -111,7 +111,9 @@ pub struct ChatPanel { pub struct ProjectPanel { #[serde(flatten)] pub container: ContainerStyle, - pub entry: TextStyle, + pub entry_base_padding: f32, + pub entry: ContainedText, + pub hovered_entry: ContainedText, } #[derive(Deserialize)] diff --git a/zed/src/worktree.rs b/zed/src/worktree.rs index 7a412d34f7d7228ad3e0ac715fc765e033cc1d1d..8bb005ed50b73e69aa674b7534d21c5e22848706 100644 --- a/zed/src/worktree.rs +++ b/zed/src/worktree.rs @@ -1592,7 +1592,6 @@ impl Snapshot { } fn insert_entry(&mut self, mut entry: Entry, fs: &dyn Fs) -> Entry { - println!("insert entry {:?}", entry.path); if !entry.is_dir() && entry.path.file_name() == Some(&GITIGNORE) { let abs_path = self.abs_path.join(&entry.path); match build_gitignore(&abs_path, fs) { @@ -1665,10 +1664,8 @@ impl Snapshot { fn reuse_entry_id(&mut self, entry: &mut Entry) { if let Some(removed_entry_id) = self.removed_entry_ids.remove(&entry.inode) { - log::info!("reusing removed entry id {}", removed_entry_id); entry.id = removed_entry_id; } else if let Some(existing_entry) = self.entry_for_path(&entry.path) { - log::info!("reusing removed entry id {}", existing_entry.id); entry.id = existing_entry.id; } } @@ -2234,7 +2231,11 @@ impl BackgroundScanner { new_ignore = Some(ignore); } Err(error) => { - log::error!("error loading .gitignore file {:?} - {:?}", child_name, error); + log::error!( + "error loading .gitignore file {:?} - {:?}", + child_name, + error + ); } }