Fix prediction preview binding: Alt + Preview -> Alt Preview (#24220)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-02-04 12:32:30 -07:00 committed by GitHub
parent b5d4b17f60
commit f8c436fe7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 24 deletions

View file

@ -5511,6 +5511,11 @@ impl Editor {
let has_completion = self.active_inline_completion.is_some(); let has_completion = self.active_inline_completion.is_some();
let is_move = self
.active_inline_completion
.as_ref()
.map_or(false, |c| c.is_move());
Some( Some(
h_flex() h_flex()
.h(self.edit_prediction_cursor_popover_height()) .h(self.edit_prediction_cursor_popover_height())
@ -5539,23 +5544,18 @@ impl Editor {
} else { } else {
None None
}, },
!is_move,
)), )),
) )
.opacity(if has_completion { 1.0 } else { 0.1 }) .opacity(if has_completion { 1.0 } else { 0.1 })
.child( .child(if is_move {
if self
.active_inline_completion
.as_ref()
.map_or(false, |c| c.is_move())
{
div() div()
.child(ui::Key::new(&accept_keystroke.key, None)) .child(ui::Key::new(&accept_keystroke.key, None))
.font(buffer_font.clone()) .font(buffer_font.clone())
.into_any() .into_any()
} else { } else {
Label::new("Preview").color(Color::Muted).into_any_element() Label::new("Preview").color(Color::Muted).into_any_element()
}, }),
),
) )
.into_any(), .into_any(),
) )

View file

@ -5869,6 +5869,7 @@ fn inline_completion_accept_indicator(
&accept_keystroke.modifiers, &accept_keystroke.modifiers,
PlatformStyle::platform(), PlatformStyle::platform(),
Some(Color::Default), Some(Color::Default),
false,
)) ))
}) })
.child(accept_keystroke.key.clone()); .child(accept_keystroke.key.clone());

View file

@ -83,6 +83,7 @@ impl RenderOnce for KeyBinding {
&keystroke.modifiers, &keystroke.modifiers,
self.platform_style, self.platform_style,
None, None,
false,
)) ))
.map(|el| el.child(render_key(&keystroke, self.platform_style, None))) .map(|el| el.child(render_key(&keystroke, self.platform_style, None)))
})) }))
@ -129,6 +130,7 @@ pub fn render_modifiers(
modifiers: &Modifiers, modifiers: &Modifiers,
platform_style: PlatformStyle, platform_style: PlatformStyle,
color: Option<Color>, color: Option<Color>,
standalone: bool,
) -> impl Iterator<Item = AnyElement> { ) -> impl Iterator<Item = AnyElement> {
enum KeyOrIcon { enum KeyOrIcon {
Key(&'static str), Key(&'static str),
@ -179,18 +181,23 @@ pub fn render_modifiers(
] ]
}; };
table let filtered = table
.into_iter() .into_iter()
.flat_map(move |modifier| { .filter(|modifier| modifier.enabled)
if modifier.enabled { .collect::<Vec<_>>();
match platform_style { let last_ix = filtered.len().saturating_sub(1);
filtered
.into_iter()
.enumerate()
.flat_map(move |(ix, modifier)| match platform_style {
PlatformStyle::Mac => vec![modifier.mac], PlatformStyle::Mac => vec![modifier.mac],
PlatformStyle::Linux if standalone && ix == last_ix => vec![modifier.linux],
PlatformStyle::Linux => vec![modifier.linux, KeyOrIcon::Key("+")], PlatformStyle::Linux => vec![modifier.linux, KeyOrIcon::Key("+")],
PlatformStyle::Windows if standalone && ix == last_ix => {
vec![modifier.windows]
}
PlatformStyle::Windows => vec![modifier.windows, KeyOrIcon::Key("+")], PlatformStyle::Windows => vec![modifier.windows, KeyOrIcon::Key("+")],
}
} else {
vec![]
}
}) })
.map(move |key_or_icon| match key_or_icon { .map(move |key_or_icon| match key_or_icon {
KeyOrIcon::Key(key) => Key::new(key, color).into_any_element(), KeyOrIcon::Key(key) => Key::new(key, color).into_any_element(),