mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 19:10:24 +00:00
Allow for folders or chevrons
This commit is contained in:
parent
a7695c47bf
commit
13ae1249f5
1 changed files with 18 additions and 23 deletions
|
@ -1176,9 +1176,9 @@ impl ProjectPanel {
|
|||
}
|
||||
|
||||
let end_ix = range.end.min(ix + visible_worktree_entries.len());
|
||||
let (git_status_setting, show_file_icons) = {
|
||||
let (git_status_setting, show_file_icons, show_folder_icons) = {
|
||||
let settings = settings::get::<ProjectPanelSettings>(cx);
|
||||
(settings.git_status, settings.file_icons)
|
||||
(settings.git_status, settings.file_icons, settings.folder_icons)
|
||||
};
|
||||
if let Some(worktree) = self.project.read(cx).worktree_for_id(*worktree_id, cx) {
|
||||
let snapshot = worktree.read(cx).snapshot();
|
||||
|
@ -1193,10 +1193,18 @@ impl ProjectPanel {
|
|||
for entry in visible_worktree_entries[entry_range].iter() {
|
||||
let status = git_status_setting.then(|| entry.git_status).flatten();
|
||||
let is_expanded = expanded_entry_ids.binary_search(&entry.id).is_ok();
|
||||
let icon = show_file_icons.then(|| match entry.kind {
|
||||
EntryKind::File(_) => FileAssociations::get_icon(&entry.path, cx),
|
||||
_ => FileAssociations::get_folder_icon(is_expanded, cx),
|
||||
});
|
||||
let icon = match entry.kind {
|
||||
EntryKind::File(_) => if show_file_icons {
|
||||
Some(FileAssociations::get_icon(&entry.path, cx))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
_ => if show_folder_icons {
|
||||
Some(FileAssociations::get_folder_icon(is_expanded, cx))
|
||||
} else {
|
||||
Some(FileAssociations::get_chevron_icon(is_expanded, cx))
|
||||
},
|
||||
};
|
||||
|
||||
let mut details = EntryDetails {
|
||||
filename: entry
|
||||
|
@ -1258,7 +1266,6 @@ impl ProjectPanel {
|
|||
style: &ProjectPanelEntry,
|
||||
cx: &mut ViewContext<V>,
|
||||
) -> AnyElement<V> {
|
||||
let kind = details.kind;
|
||||
let show_editor = details.is_editing && !details.is_processing;
|
||||
|
||||
let mut filename_text_style = style.text.clone();
|
||||
|
@ -1282,26 +1289,14 @@ impl ProjectPanel {
|
|||
.aligned()
|
||||
.constrained()
|
||||
.with_width(style.icon_size)
|
||||
} else if kind.is_dir() {
|
||||
if details.is_expanded {
|
||||
Svg::new("icons/chevron_down_8.svg").with_color(style.chevron_color)
|
||||
} else {
|
||||
Svg::new("icons/chevron_right_8.svg").with_color(style.chevron_color)
|
||||
}
|
||||
.constrained()
|
||||
.with_max_width(style.chevron_size)
|
||||
.with_max_height(style.chevron_size)
|
||||
.aligned()
|
||||
.constrained()
|
||||
.with_width(style.chevron_size)
|
||||
} else {
|
||||
} else {
|
||||
Empty::new()
|
||||
.constrained()
|
||||
.with_max_width(style.chevron_size)
|
||||
.with_max_height(style.chevron_size)
|
||||
.with_max_width(style.icon_size)
|
||||
.with_max_height(style.icon_size)
|
||||
.aligned()
|
||||
.constrained()
|
||||
.with_width(style.chevron_size)
|
||||
.with_width(style.icon_size)
|
||||
})
|
||||
.with_child(if show_editor && editor.is_some() {
|
||||
ChildView::new(editor.as_ref().unwrap(), cx)
|
||||
|
|
Loading…
Reference in a new issue