keymap_ui: Ensure keybind with empty arguments can be saved (#36393)
Follow up to #36278 to ensure this bug is actually fixed. Also fixes this on two layers and adds a test for the lower layer, as we cannot properly test it in the UI. Furthermore, this improves the error message to show some more context and ensures the status toast is actually only shown when the keybind was successfully updated: Before, we would show the success toast whilst also showing an error in the editor. Lastly, this also fixes some issues with the status toast (and animations) where no status toast or no animation would show in certain scenarios. Release Notes: - N/A
This commit is contained in:
parent
d83f341d27
commit
843336970a
4 changed files with 93 additions and 74 deletions
|
@ -31,7 +31,7 @@ pub enum AnimationDirection {
|
|||
FromTop,
|
||||
}
|
||||
|
||||
pub trait DefaultAnimations: Styled + Sized {
|
||||
pub trait DefaultAnimations: Styled + Sized + Element {
|
||||
fn animate_in(
|
||||
self,
|
||||
animation_type: AnimationDirection,
|
||||
|
@ -44,8 +44,13 @@ pub trait DefaultAnimations: Styled + Sized {
|
|||
AnimationDirection::FromTop => "animate_from_top",
|
||||
};
|
||||
|
||||
let animation_id = self.id().map_or_else(
|
||||
|| ElementId::from(animation_name),
|
||||
|id| (id, animation_name).into(),
|
||||
);
|
||||
|
||||
self.with_animation(
|
||||
animation_name,
|
||||
animation_id,
|
||||
gpui::Animation::new(AnimationDuration::Fast.into()).with_easing(ease_out_quint()),
|
||||
move |mut this, delta| {
|
||||
let start_opacity = 0.4;
|
||||
|
@ -91,7 +96,7 @@ pub trait DefaultAnimations: Styled + Sized {
|
|||
}
|
||||
}
|
||||
|
||||
impl<E: Styled> DefaultAnimations for E {}
|
||||
impl<E: Styled + Element> DefaultAnimations for E {}
|
||||
|
||||
// Don't use this directly, it only exists to show animation previews
|
||||
#[derive(RegisterComponent)]
|
||||
|
@ -132,7 +137,7 @@ impl Component for Animation {
|
|||
.left(px(offset))
|
||||
.rounded_md()
|
||||
.bg(gpui::red())
|
||||
.animate_in(AnimationDirection::FromBottom, false),
|
||||
.animate_in_from_bottom(false),
|
||||
)
|
||||
.into_any_element(),
|
||||
),
|
||||
|
@ -151,7 +156,7 @@ impl Component for Animation {
|
|||
.left(px(offset))
|
||||
.rounded_md()
|
||||
.bg(gpui::blue())
|
||||
.animate_in(AnimationDirection::FromTop, false),
|
||||
.animate_in_from_top(false),
|
||||
)
|
||||
.into_any_element(),
|
||||
),
|
||||
|
@ -170,7 +175,7 @@ impl Component for Animation {
|
|||
.top(px(offset))
|
||||
.rounded_md()
|
||||
.bg(gpui::green())
|
||||
.animate_in(AnimationDirection::FromLeft, false),
|
||||
.animate_in_from_left(false),
|
||||
)
|
||||
.into_any_element(),
|
||||
),
|
||||
|
@ -189,7 +194,7 @@ impl Component for Animation {
|
|||
.top(px(offset))
|
||||
.rounded_md()
|
||||
.bg(gpui::yellow())
|
||||
.animate_in(AnimationDirection::FromRight, false),
|
||||
.animate_in_from_right(false),
|
||||
)
|
||||
.into_any_element(),
|
||||
),
|
||||
|
@ -214,7 +219,7 @@ impl Component for Animation {
|
|||
.left(px(offset))
|
||||
.rounded_md()
|
||||
.bg(gpui::red())
|
||||
.animate_in(AnimationDirection::FromBottom, true),
|
||||
.animate_in_from_bottom(true),
|
||||
)
|
||||
.into_any_element(),
|
||||
),
|
||||
|
@ -233,7 +238,7 @@ impl Component for Animation {
|
|||
.left(px(offset))
|
||||
.rounded_md()
|
||||
.bg(gpui::blue())
|
||||
.animate_in(AnimationDirection::FromTop, true),
|
||||
.animate_in_from_top(true),
|
||||
)
|
||||
.into_any_element(),
|
||||
),
|
||||
|
@ -252,7 +257,7 @@ impl Component for Animation {
|
|||
.top(px(offset))
|
||||
.rounded_md()
|
||||
.bg(gpui::green())
|
||||
.animate_in(AnimationDirection::FromLeft, true),
|
||||
.animate_in_from_left(true),
|
||||
)
|
||||
.into_any_element(),
|
||||
),
|
||||
|
@ -271,7 +276,7 @@ impl Component for Animation {
|
|||
.top(px(offset))
|
||||
.rounded_md()
|
||||
.bg(gpui::yellow())
|
||||
.animate_in(AnimationDirection::FromRight, true),
|
||||
.animate_in_from_right(true),
|
||||
)
|
||||
.into_any_element(),
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue