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 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);
|
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) {
|
if let Some(worktree) = self.project.read(cx).worktree_for_id(*worktree_id, cx) {
|
||||||
let snapshot = worktree.read(cx).snapshot();
|
let snapshot = worktree.read(cx).snapshot();
|
||||||
|
@ -1193,10 +1193,18 @@ impl ProjectPanel {
|
||||||
for entry in visible_worktree_entries[entry_range].iter() {
|
for entry in visible_worktree_entries[entry_range].iter() {
|
||||||
let status = git_status_setting.then(|| entry.git_status).flatten();
|
let status = git_status_setting.then(|| entry.git_status).flatten();
|
||||||
let is_expanded = expanded_entry_ids.binary_search(&entry.id).is_ok();
|
let is_expanded = expanded_entry_ids.binary_search(&entry.id).is_ok();
|
||||||
let icon = show_file_icons.then(|| match entry.kind {
|
let icon = match entry.kind {
|
||||||
EntryKind::File(_) => FileAssociations::get_icon(&entry.path, cx),
|
EntryKind::File(_) => if show_file_icons {
|
||||||
_ => FileAssociations::get_folder_icon(is_expanded, cx),
|
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 {
|
let mut details = EntryDetails {
|
||||||
filename: entry
|
filename: entry
|
||||||
|
@ -1258,7 +1266,6 @@ impl ProjectPanel {
|
||||||
style: &ProjectPanelEntry,
|
style: &ProjectPanelEntry,
|
||||||
cx: &mut ViewContext<V>,
|
cx: &mut ViewContext<V>,
|
||||||
) -> AnyElement<V> {
|
) -> AnyElement<V> {
|
||||||
let kind = details.kind;
|
|
||||||
let show_editor = details.is_editing && !details.is_processing;
|
let show_editor = details.is_editing && !details.is_processing;
|
||||||
|
|
||||||
let mut filename_text_style = style.text.clone();
|
let mut filename_text_style = style.text.clone();
|
||||||
|
@ -1282,26 +1289,14 @@ impl ProjectPanel {
|
||||||
.aligned()
|
.aligned()
|
||||||
.constrained()
|
.constrained()
|
||||||
.with_width(style.icon_size)
|
.with_width(style.icon_size)
|
||||||
} else if kind.is_dir() {
|
} else {
|
||||||
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 {
|
|
||||||
Empty::new()
|
Empty::new()
|
||||||
.constrained()
|
.constrained()
|
||||||
.with_max_width(style.chevron_size)
|
.with_max_width(style.icon_size)
|
||||||
.with_max_height(style.chevron_size)
|
.with_max_height(style.icon_size)
|
||||||
.aligned()
|
.aligned()
|
||||||
.constrained()
|
.constrained()
|
||||||
.with_width(style.chevron_size)
|
.with_width(style.icon_size)
|
||||||
})
|
})
|
||||||
.with_child(if show_editor && editor.is_some() {
|
.with_child(if show_editor && editor.is_some() {
|
||||||
ChildView::new(editor.as_ref().unwrap(), cx)
|
ChildView::new(editor.as_ref().unwrap(), cx)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue