Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
nervenes committed Nov 4, 2024
1 parent 2b16fa4 commit faf097e
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 115 deletions.
10 changes: 2 additions & 8 deletions crates/editor/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,7 @@ impl Item for Editor {
.as_singleton()
.and_then(|buffer| buffer.read(cx).project_path(cx))
.and_then(|path| self.project.as_ref()?.read(cx).entry_for_path(&path, cx))
.map(|entry| {
git_aware_color(entry.git_status, entry.is_ignored, params.selected)
})
.map(|entry| git_aware_color(entry.git_status, entry.is_ignored, params.selected))
.unwrap_or_else(|| regular_color(params.selected))
} else {
regular_color(params.selected)
Expand Down Expand Up @@ -1512,11 +1510,7 @@ pub fn regular_color(selected: bool) -> Color {
}
}

pub fn git_aware_color(
git_status: Option<GitFileStatus>,
ignored: bool,
selected: bool,
) -> Color {
pub fn git_aware_color(git_status: Option<GitFileStatus>, ignored: bool, selected: bool) -> Color {
if ignored {
Color::Ignored
} else {
Expand Down
6 changes: 2 additions & 4 deletions crates/outline_panel/src/outline_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1728,8 +1728,7 @@ impl OutlinePanel {
let (item_id, label_element, icon) = match rendered_entry {
FsEntry::File(worktree_id, entry, ..) => {
let name = self.entry_name(worktree_id, entry, cx);
let color =
git_aware_color(entry.git_status, entry.is_ignored, is_active);
let color = git_aware_color(entry.git_status, entry.is_ignored, is_active);
let icon = if settings.file_icons {
FileIcons::get_icon(&entry.path, cx)
.map(|icon_path| Icon::from_path(icon_path).color(color).into_any_element())
Expand All @@ -1755,8 +1754,7 @@ impl OutlinePanel {
let is_expanded = !self
.collapsed_entries
.contains(&CollapsedEntry::Dir(*worktree_id, entry.id));
let color =
git_aware_color(entry.git_status, entry.is_ignored, is_active);
let color = git_aware_color(entry.git_status, entry.is_ignored, is_active);
let icon = if settings.folder_icons {
FileIcons::get_folder_icon(is_expanded, cx)
} else {
Expand Down
133 changes: 62 additions & 71 deletions crates/project_panel/src/project_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2586,37 +2586,55 @@ impl ProjectPanel {
.indent_level(depth)
.indent_step_size(px(settings.indent_size))
.selected(is_marked || is_active)
.when(
canonical_path.is_some() || settings.git_status,
|this| {
this.end_slot(
h_flex()
.id("git_symbol")
.size_3()
.justify_center()
.mr_3()
.when_some(canonical_path, |this, path| {
this.child(
div()
.id("symlink_icon")
.tooltip(move |cx| {
Tooltip::with_meta(
path.to_string(),
None,
"Symbolic Link",
cx,
)
})
.child(
Icon::new(IconName::ArrowUpRight)
.size(IconSize::Indicator)
.color(color),
.when(canonical_path.is_some() || settings.git_status, |this| {
this.end_slot(
h_flex()
.id("git_symbol")
.size_3()
.justify_center()
.mr_3()
.when_some(canonical_path, |this, path| {
this.child(
div()
.id("symlink_icon")
.tooltip(move |cx| {
Tooltip::with_meta(
path.to_string(),
None,
"Symbolic Link",
cx,
)
.into_any_element(),
)
})
.child(
Icon::new(IconName::ArrowUpRight)
.size(IconSize::Indicator)
.color(color),
)
.into_any_element(),
)
})
.when_some(git_status, |this, git_status| {
this.when(entry_details.is_folder, |this| {
this.tooltip(move |cx| {
Tooltip::text(
match git_status {
GitFileStatus::Added => "Untracked".to_string(),
GitFileStatus::Modified => {
"Modified".to_string()
}
GitFileStatus::Conflict => {
"Conflict".to_string()
}
},
cx,
)
})
.child(Indicator::dot().color(color))
.opacity(0.5)
})
.when_some(git_status, |this, git_status| {
this.when(entry_details.is_folder, |this| {
.when(
entry_details.is_file,
|this| {
this.tooltip(move |cx| {
Tooltip::text(
match git_status {
Expand All @@ -2633,44 +2651,21 @@ impl ProjectPanel {
cx,
)
})
.child(Indicator::dot().color(color))
.opacity(0.5)
})
.when(
entry_details.is_file,
|this| {
this.tooltip(move |cx| {
Tooltip::text(
match git_status {
GitFileStatus::Added => {
"Untracked".to_string()
}
GitFileStatus::Modified => {
"Modified".to_string()
}
GitFileStatus::Conflict => {
"Conflict".to_string()
}
},
cx,
)
.child(
Label::new(match git_status {
GitFileStatus::Added => "U",
GitFileStatus::Modified => "M",
GitFileStatus::Conflict => "C",
})
.child(
Label::new(match git_status {
GitFileStatus::Added => "U",
GitFileStatus::Modified => "M",
GitFileStatus::Conflict => "C",
})
.weight(FontWeight::BOLD)
.size(LabelSize::XSmall)
.color(color),
)
},
)
}),
)
},
)
.weight(FontWeight::BOLD)
.size(LabelSize::XSmall)
.color(color),
)
},
)
}),
)
})
.child(if let Some(icon) = &icon {
h_flex().child(Icon::from_path(icon.to_string()).color(color))
} else {
Expand Down Expand Up @@ -2740,11 +2735,7 @@ impl ProjectPanel {

this
} else {
this.child(
Label::new(file_name)
.single_line()
.color(color),
)
this.child(Label::new(file_name).single_line().color(color))
}
})
}
Expand Down
11 changes: 3 additions & 8 deletions crates/tab_switcher/src/tab_switcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,20 +351,15 @@ impl PickerDelegate for TabSwitcherDelegate {
let label = tab_match.item.tab_content(params, cx);

let icon = tab_match.item.tab_icon(cx).map(|icon| {
let git_status_color = ItemSettings::get_global(cx).git_colors
let git_status_color = ItemSettings::get_global(cx)
.git_colors
.then(|| {
tab_match
.item
.project_path(cx)
.as_ref()
.and_then(|path| self.project.read(cx).entry_for_path(path, cx))
.map(|entry| {
git_aware_color(
entry.git_status,
entry.is_ignored,
selected,
)
})
.map(|entry| git_aware_color(entry.git_status, entry.is_ignored, selected))
})
.flatten();

Expand Down
48 changes: 24 additions & 24 deletions crates/workspace/src/pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1994,31 +1994,31 @@ impl Pane {
})
})
.when(settings.git_status, |this| {
this.child(div().id("git_symbol").when_some(
git_status,
|this, git_status| {
this.tooltip(move |cx| {
Tooltip::text(
match git_status {
GitFileStatus::Added => "Untracked".to_string(),
GitFileStatus::Modified => "Modified".to_string(),
GitFileStatus::Conflict => "Conflict".to_string(),
},
cx,
)
})
.child(
Label::new(match git_status {
GitFileStatus::Added => "U",
GitFileStatus::Modified => "M",
GitFileStatus::Conflict => "C",
})
.weight(FontWeight::BOLD)
.size(LabelSize::XSmall)
.color(color),
this.child(div().id("git_symbol").when_some(
git_status,
|this, git_status| {
this.tooltip(move |cx| {
Tooltip::text(
match git_status {
GitFileStatus::Added => "Untracked".to_string(),
GitFileStatus::Modified => "Modified".to_string(),
GitFileStatus::Conflict => "Conflict".to_string(),
},
cx,
)
},
))
})
.child(
Label::new(match git_status {
GitFileStatus::Added => "U",
GitFileStatus::Modified => "M",
GitFileStatus::Conflict => "C",
})
.weight(FontWeight::BOLD)
.size(LabelSize::XSmall)
.color(color),
)
},
))
}),
)
.map(|this| {
Expand Down

0 comments on commit faf097e

Please sign in to comment.