edit predictions: Handle no keybind for preview (#25015)
If the user removes all modified keybinds in `edit_prediction_conflict`, the preview bar above the completions menu would disappear. This PR handles that case slightly better by still showing the 1-line preview (which they might accept via an unmodified keybind) and hides the `| Preview ⌥` section since it's impossible to invoke in this case. Release Notes: - Handle `edit_prediction_conflict` context without modified keybinds for `AcceptEditPrediction`
This commit is contained in:
parent
08e9080ec9
commit
478bccadd6
2 changed files with 38 additions and 32 deletions
|
@ -5762,7 +5762,7 @@ impl Editor {
|
||||||
max_width: Pixels,
|
max_width: Pixels,
|
||||||
cursor_point: Point,
|
cursor_point: Point,
|
||||||
style: &EditorStyle,
|
style: &EditorStyle,
|
||||||
accept_keystroke: &gpui::Keystroke,
|
accept_keystroke: Option<&gpui::Keystroke>,
|
||||||
_window: &Window,
|
_window: &Window,
|
||||||
cx: &mut Context<Editor>,
|
cx: &mut Context<Editor>,
|
||||||
) -> Option<AnyElement> {
|
) -> Option<AnyElement> {
|
||||||
|
@ -5841,7 +5841,7 @@ impl Editor {
|
||||||
)
|
)
|
||||||
.child(Label::new("Hold").size(LabelSize::Small))
|
.child(Label::new("Hold").size(LabelSize::Small))
|
||||||
.child(h_flex().children(ui::render_modifiers(
|
.child(h_flex().children(ui::render_modifiers(
|
||||||
&accept_keystroke.modifiers,
|
&accept_keystroke?.modifiers,
|
||||||
PlatformStyle::platform(),
|
PlatformStyle::platform(),
|
||||||
Some(Color::Default),
|
Some(Color::Default),
|
||||||
Some(IconSize::Small.rems().into()),
|
Some(IconSize::Small.rems().into()),
|
||||||
|
@ -5906,35 +5906,41 @@ impl Editor {
|
||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
.child(completion),
|
.child(completion),
|
||||||
)
|
)
|
||||||
.child(
|
.when_some(accept_keystroke, |el, accept_keystroke| {
|
||||||
h_flex()
|
if !accept_keystroke.modifiers.modified() {
|
||||||
.h_full()
|
return el;
|
||||||
.border_l_1()
|
}
|
||||||
.rounded_r_lg()
|
|
||||||
.border_color(cx.theme().colors().border)
|
el.child(
|
||||||
.bg(Self::edit_prediction_line_popover_bg_color(cx))
|
h_flex()
|
||||||
.gap_1()
|
.h_full()
|
||||||
.py_1()
|
.border_l_1()
|
||||||
.px_2()
|
.rounded_r_lg()
|
||||||
.child(
|
.border_color(cx.theme().colors().border)
|
||||||
h_flex()
|
.bg(Self::edit_prediction_line_popover_bg_color(cx))
|
||||||
.font(theme::ThemeSettings::get_global(cx).buffer_font.clone())
|
.gap_1()
|
||||||
.when(is_platform_style_mac, |parent| parent.gap_1())
|
.py_1()
|
||||||
.child(h_flex().children(ui::render_modifiers(
|
.px_2()
|
||||||
&accept_keystroke.modifiers,
|
.child(
|
||||||
PlatformStyle::platform(),
|
h_flex()
|
||||||
Some(if !has_completion {
|
.font(theme::ThemeSettings::get_global(cx).buffer_font.clone())
|
||||||
Color::Muted
|
.when(is_platform_style_mac, |parent| parent.gap_1())
|
||||||
} else {
|
.child(h_flex().children(ui::render_modifiers(
|
||||||
Color::Default
|
&accept_keystroke.modifiers,
|
||||||
}),
|
PlatformStyle::platform(),
|
||||||
None,
|
Some(if !has_completion {
|
||||||
false,
|
Color::Muted
|
||||||
))),
|
} else {
|
||||||
)
|
Color::Default
|
||||||
.child(Label::new("Preview").into_any_element())
|
}),
|
||||||
.opacity(if has_completion { 1.0 } else { 0.4 }),
|
None,
|
||||||
)
|
false,
|
||||||
|
))),
|
||||||
|
)
|
||||||
|
.child(Label::new("Preview").into_any_element())
|
||||||
|
.opacity(if has_completion { 1.0 } else { 0.4 }),
|
||||||
|
)
|
||||||
|
})
|
||||||
.into_any(),
|
.into_any(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3255,7 +3255,7 @@ impl EditorElement {
|
||||||
max_width,
|
max_width,
|
||||||
cursor_point,
|
cursor_point,
|
||||||
style,
|
style,
|
||||||
accept_binding.keystroke()?,
|
accept_binding.keystroke(),
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
)?;
|
)?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue