History

Style filenames and paths in project diff buffer headers according to git status (#25653)

This substitutes for the icons that we previously kept in these headers. cc @iamnbutler Release Notes: - N/A

Cole Miller committed 1 year ago

Commit eeac1a91 parent e83ebd11 file · +45 −6Browse files

Unified · Split

crates/editor/src/element.rs+45−6
@@ -28,7 +28,7 @@ use buffer_diff::{DiffHunkSecondaryStatus, DiffHunkStatus, DiffHunkStatusKind}; · 27 unmodified lines
28use client::ParticipantIndex;28use client::ParticipantIndex;
29use collections::{BTreeMap, HashMap, HashSet};29use collections::{BTreeMap, HashMap, HashSet};
30use file_icons::FileIcons;30use file_icons::FileIcons;
31use git::{blame::BlameEntry, Oid};31use git::{blame::BlameEntry, status::FileStatus, Oid};
32use gpui::{32use gpui::{
33 anchored, deferred, div, fill, linear_color_stop, linear_gradient, outline, point, px, quad,33 anchored, deferred, div, fill, linear_color_stop, linear_gradient, outline, point, px, quad,
34 relative, size, svg, transparent_black, Action, AnyElement, App, AvailableSpace, Axis, Bounds,34 relative, size, svg, transparent_black, Action, AnyElement, App, AvailableSpace, Axis, Bounds,
@@ -73,7 +73,7 @@ use ui::{ · 38 unmodified lines
73 POPOVER_Y_PADDING,73 POPOVER_Y_PADDING,
74};74};
75use unicode_segmentation::UnicodeSegmentation;75use unicode_segmentation::UnicodeSegmentation;
76use util::{debug_panic, RangeExt, ResultExt};76use util::{debug_panic, maybe, RangeExt, ResultExt};
77use workspace::{item::Item, notifications::NotifyTaskExt};77use workspace::{item::Item, notifications::NotifyTaskExt};
78 78
79const INLINE_BLAME_PADDING_EM_WIDTHS: f32 = 7.;79const INLINE_BLAME_PADDING_EM_WIDTHS: f32 = 7.;
@@ -2646,6 +2646,21 @@ impl EditorElement { · 2566 unmodified lines
2646 window: &mut Window,2646 window: &mut Window,
2647 cx: &mut App,2647 cx: &mut App,
2648 ) -> Div {2648 ) -> Div {
2649 let file_status = maybe!({
2650 let project = self.editor.read(cx).project.as_ref()?.read(cx);
2651 let (repo, path) =
2652 project.repository_and_path_for_buffer_id(for_excerpt.buffer_id, cx)?;
2653 let status = repo.read(cx).repository_entry.status_for_path(&path)?;
2654 Some(status.status)
2655 })
2656 .filter(|_| {
2657 self.editor
2658 .read(cx)
2659 .buffer
2660 .read(cx)
2661 .all_diff_hunks_expanded()
2662 });
2663
2649 let include_root = self2664 let include_root = self
2650 .editor2665 .editor
2651 .read(cx)2666 .read(cx)
@@ -2749,12 +2764,36 @@ impl EditorElement { · 97 unmodified lines
2749 h_flex()2764 h_flex()
2750 .gap_2()2765 .gap_2()
2751 .child(2766 .child(
2752 filename2767 Label::new(
2753 .map(SharedString::from)2768 filename
2754 .unwrap_or_else(|| "untitled".into()),2769 .map(SharedString::from)
2770 .unwrap_or_else(|| "untitled".into()),
2771 )
2772 .single_line()
2773 .when_some(
2774 file_status,
2775 |el, status| {
2776 el.color(if status.is_conflicted() {
2777 Color::Conflict
2778 } else if status.is_modified() {
2779 Color::Modified
2780 } else if status.is_deleted() {
2781 Color::Disabled
2782 } else {
2783 Color::Created
2784 })
2785 .when(status.is_deleted(), |el| el.strikethrough())
2786 },
2787 ),
2755 )2788 )
2756 .when_some(parent_path, |then, path| {2789 .when_some(parent_path, |then, path| {
2757 then.child(div().child(path).text_color(colors.text_muted))2790 then.child(div().child(path).text_color(
2791 if file_status.is_some_and(FileStatus::is_deleted) {
2792 colors.text_disabled
2793 } else {
2794 colors.text_muted
2795 },
2796 ))
2758 }),2797 }),
2759 )2798 )
2760 .when(is_selected, |el| {2799 .when(is_selected, |el| {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t