From bff1548b48815cb0b1915f48aa1b1231006b5d33 Mon Sep 17 00:00:00 2001
From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com>
Date: Tue, 18 Feb 2025 18:22:01 -0300
Subject: [PATCH] assistant2: Add file icons for mentioned creases (#25111)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This PR makes the mentioned file creases/buttons use `FileIcons`.
Release Notes:
- N/A
Co-authored-by: Anthony Eid
---
.../src/context_picker/file_context_picker.rs | 23 +++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/crates/assistant2/src/context_picker/file_context_picker.rs b/crates/assistant2/src/context_picker/file_context_picker.rs
index 757249dbea59c1af76db14ee032c329623c2959c..cab317a1ea14d73d572574fb3f5dac8f60f31dc1 100644
--- a/crates/assistant2/src/context_picker/file_context_picker.rs
+++ b/crates/assistant2/src/context_picker/file_context_picker.rs
@@ -288,8 +288,11 @@ impl PickerDelegate for FileContextPickerDelegate {
editor.insert("\n", window, cx); // Needed to end the fold
+ let file_icon = FileIcons::get_icon(&Path::new(&full_path), cx)
+ .unwrap_or_else(|| SharedString::new(""));
+
let placeholder = FoldPlaceholder {
- render: render_fold_icon_button(IconName::File, file_name.into()),
+ render: render_fold_icon_button(file_icon, file_name.into()),
..Default::default()
};
@@ -459,15 +462,27 @@ pub fn render_file_context_entry(
}
fn render_fold_icon_button(
- icon: IconName,
+ icon: SharedString,
label: SharedString,
) -> Arc, &mut Window, &mut App) -> AnyElement> {
Arc::new(move |fold_id, _fold_range, _window, _cx| {
ButtonLike::new(fold_id)
.style(ButtonStyle::Filled)
.layer(ElevationIndex::ElevatedSurface)
- .child(Icon::new(icon))
- .child(Label::new(label.clone()).single_line())
+ .child(
+ h_flex()
+ .gap_1()
+ .child(
+ Icon::from_path(icon.clone())
+ .size(IconSize::Small)
+ .color(Color::Muted),
+ )
+ .child(
+ Label::new(label.clone())
+ .size(LabelSize::Small)
+ .single_line(),
+ ),
+ )
.into_any_element()
})
}