This commit is contained in:
Matt 2025-08-27 00:39:16 +08:00 committed by GitHub
commit eff25f3f2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,7 +22,7 @@ use itertools::Itertools as _;
use picker::{Picker, PickerDelegate, highlighted_match_with_paths::HighlightedMatch}; use picker::{Picker, PickerDelegate, highlighted_match_with_paths::HighlightedMatch};
use project::{DebugScenarioContext, TaskContexts, TaskSourceKind, task_store::TaskStore}; use project::{DebugScenarioContext, TaskContexts, TaskSourceKind, task_store::TaskStore};
use settings::Settings; use settings::Settings;
use task::{DebugScenario, RevealTarget, ZedDebugConfig}; use task::{DebugScenario, RevealTarget, VariableName, ZedDebugConfig};
use theme::ThemeSettings; use theme::ThemeSettings;
use ui::{ use ui::{
ActiveTheme, Button, ButtonCommon, ButtonSize, CheckboxWithLabel, Clickable, Color, Context, ActiveTheme, Button, ButtonCommon, ButtonSize, CheckboxWithLabel, Clickable, Color, Context,
@ -1429,7 +1429,8 @@ impl PickerDelegate for DebugDelegate {
window: &mut Window, window: &mut Window,
cx: &mut Context<picker::Picker<Self>>, cx: &mut Context<picker::Picker<Self>>,
) -> Option<Self::ListItem> { ) -> Option<Self::ListItem> {
let hit = &self.matches[ix]; let hit = self.matches.get(ix)?;
let (task_kind, _scenario, context) = &self.candidates[hit.candidate_id];
let highlighted_location = HighlightedMatch { let highlighted_location = HighlightedMatch {
text: hit.string.clone(), text: hit.string.clone(),
@ -1437,33 +1438,58 @@ impl PickerDelegate for DebugDelegate {
char_count: hit.string.chars().count(), char_count: hit.string.chars().count(),
color: Color::Default, color: Color::Default,
}; };
let task_kind = &self.candidates[hit.candidate_id].0;
let icon = match task_kind { let subtitle = match task_kind {
Some(TaskSourceKind::UserInput) => Some(Icon::new(IconName::Terminal)), Some(TaskSourceKind::Worktree {
Some(TaskSourceKind::AbsPath { .. }) => Some(Icon::new(IconName::Settings)), directory_in_worktree,
Some(TaskSourceKind::Worktree { .. }) => Some(Icon::new(IconName::FileTree)),
Some(TaskSourceKind::Lsp {
language_name: name,
.. ..
}) }) => Some(directory_in_worktree.display().to_string()),
| Some(TaskSourceKind::Language { name }) => file_icons::FileIcons::get(cx) Some(TaskSourceKind::AbsPath { abs_path, .. }) => {
.get_icon_for_type(&name.to_lowercase(), cx) Some(abs_path.to_string_lossy().into_owned())
.map(Icon::from_path), }
None => Some(Icon::new(IconName::HistoryRerun)), Some(TaskSourceKind::Lsp { language_name, .. }) => {
} Some(format!("LSP: {language_name}"))
.map(|icon| icon.color(Color::Muted).size(IconSize::Small)); }
let indicator = if matches!(task_kind, Some(TaskSourceKind::Lsp { .. })) { Some(TaskSourceKind::Language { name }) => Some(format!("Language: {name}")),
Some(Indicator::icon( _ => context.clone().and_then(|ctx| {
Icon::new(IconName::BoltFilled) ctx.task_context
.color(Color::Muted) .task_variables
.size(IconSize::Small), .get(&VariableName::RelativeFile)
)) .map(|f| format!("in {f}"))
} else { .or_else(|| {
None ctx.task_context
.task_variables
.get(&VariableName::Dirname)
.map(|d| format!("in {d}/"))
})
}),
}; };
let (icon, indicator) = match task_kind {
Some(TaskSourceKind::UserInput) => (Some(Icon::new(IconName::Terminal)), None),
Some(TaskSourceKind::AbsPath { .. }) => (Some(Icon::new(IconName::Settings)), None),
Some(TaskSourceKind::Worktree { .. }) => (Some(Icon::new(IconName::FileTree)), None),
Some(TaskSourceKind::Lsp { language_name, .. }) => (
file_icons::FileIcons::get(cx)
.get_icon_for_type(&language_name.to_lowercase(), cx)
.map(Icon::from_path),
Some(Indicator::icon(
Icon::new(IconName::BoltFilled)
.color(Color::Muted)
.size(IconSize::Small),
)),
),
Some(TaskSourceKind::Language { name }) => (
file_icons::FileIcons::get(cx)
.get_icon_for_type(&name.to_lowercase(), cx)
.map(Icon::from_path),
None,
),
None => (Some(Icon::new(IconName::HistoryRerun)), None),
};
let icon = icon.map(|icon| { let icon = icon.map(|icon| {
IconWithIndicator::new(icon, indicator) IconWithIndicator::new(icon.color(Color::Muted).size(IconSize::Small), indicator)
.indicator_border_color(Some(cx.theme().colors().border_transparent)) .indicator_border_color(Some(cx.theme().colors().border_transparent))
}); });
@ -1473,7 +1499,18 @@ impl PickerDelegate for DebugDelegate {
.start_slot::<IconWithIndicator>(icon) .start_slot::<IconWithIndicator>(icon)
.spacing(ListItemSpacing::Sparse) .spacing(ListItemSpacing::Sparse)
.toggle_state(selected) .toggle_state(selected)
.child(highlighted_location.render(window, cx)), .child(
v_flex()
.items_start()
.child(highlighted_location.render(window, cx))
.when_some(subtitle, |this, subtitle_text| {
this.child(
Label::new(subtitle_text)
.size(LabelSize::Small)
.color(Color::Muted),
)
}),
),
) )
} }
} }