Fix prediction preview binding: Alt + Preview
-> Alt Preview
(#24220)
Release Notes: - N/A
This commit is contained in:
parent
b5d4b17f60
commit
f8c436fe7f
3 changed files with 32 additions and 24 deletions
|
@ -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
|
div()
|
||||||
.active_inline_completion
|
.child(ui::Key::new(&accept_keystroke.key, None))
|
||||||
.as_ref()
|
.font(buffer_font.clone())
|
||||||
.map_or(false, |c| c.is_move())
|
.into_any()
|
||||||
{
|
} else {
|
||||||
div()
|
Label::new("Preview").color(Color::Muted).into_any_element()
|
||||||
.child(ui::Key::new(&accept_keystroke.key, None))
|
}),
|
||||||
.font(buffer_font.clone())
|
|
||||||
.into_any()
|
|
||||||
} else {
|
|
||||||
Label::new("Preview").color(Color::Muted).into_any_element()
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.into_any(),
|
.into_any(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -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());
|
||||||
|
|
|
@ -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);
|
||||||
PlatformStyle::Mac => vec![modifier.mac],
|
|
||||||
PlatformStyle::Linux => vec![modifier.linux, KeyOrIcon::Key("+")],
|
filtered
|
||||||
PlatformStyle::Windows => vec![modifier.windows, KeyOrIcon::Key("+")],
|
.into_iter()
|
||||||
}
|
.enumerate()
|
||||||
} else {
|
.flat_map(move |(ix, modifier)| match platform_style {
|
||||||
vec![]
|
PlatformStyle::Mac => vec![modifier.mac],
|
||||||
|
PlatformStyle::Linux if standalone && ix == last_ix => vec![modifier.linux],
|
||||||
|
PlatformStyle::Linux => vec![modifier.linux, KeyOrIcon::Key("+")],
|
||||||
|
PlatformStyle::Windows if standalone && ix == last_ix => {
|
||||||
|
vec![modifier.windows]
|
||||||
}
|
}
|
||||||
|
PlatformStyle::Windows => vec![modifier.windows, KeyOrIcon::Key("+")],
|
||||||
})
|
})
|
||||||
.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(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue