tasks: Add spawn option by tag (#25650)
Closes #19497 Fixed conflicts from https://github.com/zed-industries/zed/pull/19498 Added tags to tasks selector Release Notes: - Added ability to spawn tasks by tag with key bindings - Added tags to tasks selector https://github.com/user-attachments/assets/0eefea21-ec4e-407c-9d4f-2a0a4a0f74df --------- Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
This commit is contained in:
parent
80441f675b
commit
2f5a4f7e80
10 changed files with 174 additions and 33 deletions
|
@ -15,10 +15,11 @@ use task::{
|
|||
};
|
||||
use ui::{
|
||||
ActiveTheme, Button, ButtonCommon, ButtonSize, Clickable, Color, FluentBuilder as _, Icon,
|
||||
IconButton, IconButtonShape, IconName, IconSize, IntoElement, KeyBinding, LabelSize, ListItem,
|
||||
ListItemSpacing, RenderOnce, Toggleable, Tooltip, div, h_flex, v_flex,
|
||||
IconButton, IconButtonShape, IconName, IconSize, IntoElement, KeyBinding, Label, LabelSize,
|
||||
ListItem, ListItemSpacing, RenderOnce, Toggleable, Tooltip, div, h_flex, v_flex,
|
||||
};
|
||||
use util::ResultExt;
|
||||
|
||||
use util::{ResultExt, truncate_and_trailoff};
|
||||
use workspace::{ModalView, Workspace, tasks::schedule_resolved_task};
|
||||
pub use zed_actions::{Rerun, Spawn};
|
||||
|
||||
|
@ -187,6 +188,8 @@ impl Focusable for TasksModal {
|
|||
|
||||
impl ModalView for TasksModal {}
|
||||
|
||||
const MAX_TAGS_LINE_LEN: usize = 30;
|
||||
|
||||
impl PickerDelegate for TasksModalDelegate {
|
||||
type ListItem = ListItem;
|
||||
|
||||
|
@ -398,6 +401,18 @@ impl PickerDelegate for TasksModalDelegate {
|
|||
tooltip_label_text.push_str(&resolved.command_label);
|
||||
}
|
||||
}
|
||||
if template.tags.len() > 0 {
|
||||
tooltip_label_text.push('\n');
|
||||
tooltip_label_text.push_str(
|
||||
template
|
||||
.tags
|
||||
.iter()
|
||||
.map(|tag| format!("\n#{}", tag))
|
||||
.collect::<Vec<_>>()
|
||||
.join("")
|
||||
.as_str(),
|
||||
);
|
||||
}
|
||||
let tooltip_label = if tooltip_label_text.trim().is_empty() {
|
||||
None
|
||||
} else {
|
||||
|
@ -439,7 +454,22 @@ impl PickerDelegate for TasksModalDelegate {
|
|||
ListItem::new(SharedString::from(format!("tasks-modal-{ix}")))
|
||||
.inset(true)
|
||||
.start_slot::<Icon>(icon)
|
||||
.end_slot::<AnyElement>(history_run_icon)
|
||||
.end_slot::<AnyElement>(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.child(Label::new(truncate_and_trailoff(
|
||||
&template
|
||||
.tags
|
||||
.iter()
|
||||
.map(|tag| format!("#{}", tag))
|
||||
.collect::<Vec<_>>()
|
||||
.join(" "),
|
||||
MAX_TAGS_LINE_LEN,
|
||||
)))
|
||||
.flex_none()
|
||||
.child(history_run_icon.unwrap())
|
||||
.into_any_element(),
|
||||
)
|
||||
.spacing(ListItemSpacing::Sparse)
|
||||
.when_some(tooltip_label, |list_item, item_label| {
|
||||
list_item.tooltip(move |_, _| item_label.clone())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue