tasks: Wire through click handlers in new tasks modal (#11854)

🤦
Spotted by @SomeoneToIgnore 


Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-05-15 14:38:19 +02:00 committed by GitHub
parent 43d79af94a
commit a59a388c15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,7 +3,7 @@ use std::sync::Arc;
use crate::active_item_selection_properties; use crate::active_item_selection_properties;
use fuzzy::{StringMatch, StringMatchCandidate}; use fuzzy::{StringMatch, StringMatchCandidate};
use gpui::{ use gpui::{
impl_actions, rems, AnyElement, AppContext, DismissEvent, EventEmitter, FocusableView, impl_actions, rems, Action, AnyElement, AppContext, DismissEvent, EventEmitter, FocusableView,
InteractiveElement, Model, ParentElement, Render, SharedString, Styled, Subscription, View, InteractiveElement, Model, ParentElement, Render, SharedString, Styled, Subscription, View,
ViewContext, VisualContext, WeakView, ViewContext, VisualContext, WeakView,
}; };
@ -475,29 +475,30 @@ impl PickerDelegate for TasksModalDelegate {
Button::new("edit-current-task", edit_entry_label) Button::new("edit-current-task", edit_entry_label)
.label_size(LabelSize::Small) .label_size(LabelSize::Small)
.key_binding(keybind) .key_binding(keybind)
.on_click(|_, cx| {
cx.dispatch_action(picker::UseSelectedQuery.boxed_clone())
})
}), }),
) )
.map(|this| { .map(|this| {
if current_modifiers.alt || self.matches.is_empty() { if (current_modifiers.alt || self.matches.is_empty()) && !self.prompt.is_empty()
this.children( {
KeyBinding::for_action( let action = picker::ConfirmInput {
&picker::ConfirmInput { secondary: current_modifiers.secondary(),
secondary: current_modifiers.secondary(), }
}, .boxed_clone();
cx, this.children(KeyBinding::for_action(&*action, cx).map(|keybind| {
) let spawn_oneshot_label = if current_modifiers.secondary() {
.map(|keybind| { "Spawn oneshot without history"
let spawn_oneshot_label = if current_modifiers.secondary() { } else {
"Spawn oneshot without history" "Spawn oneshot"
} else { };
"Spawn oneshot"
};
Button::new("spawn-onehshot", spawn_oneshot_label) Button::new("spawn-onehshot", spawn_oneshot_label)
.label_size(LabelSize::Small) .label_size(LabelSize::Small)
.key_binding(keybind) .key_binding(keybind)
}), .on_click(move |_, cx| cx.dispatch_action(action.boxed_clone()))
) }))
} else if current_modifiers.secondary() { } else if current_modifiers.secondary() {
this.children(KeyBinding::for_action(&menu::SecondaryConfirm, cx).map( this.children(KeyBinding::for_action(&menu::SecondaryConfirm, cx).map(
|keybind| { |keybind| {
@ -509,6 +510,9 @@ impl PickerDelegate for TasksModalDelegate {
Button::new("spawn", label) Button::new("spawn", label)
.label_size(LabelSize::Small) .label_size(LabelSize::Small)
.key_binding(keybind) .key_binding(keybind)
.on_click(move |_, cx| {
cx.dispatch_action(menu::SecondaryConfirm.boxed_clone())
})
}, },
)) ))
} else { } else {
@ -519,6 +523,9 @@ impl PickerDelegate for TasksModalDelegate {
Button::new("spawn", run_entry_label) Button::new("spawn", run_entry_label)
.label_size(LabelSize::Small) .label_size(LabelSize::Small)
.key_binding(keybind) .key_binding(keybind)
.on_click(|_, cx| {
cx.dispatch_action(menu::Confirm.boxed_clone());
})
})) }))
} }
}) })