Fix showing "enter Accept" for prediction with LSP menu open (#24218)
Release Notes: - N/A
This commit is contained in:
parent
3e68f7fde4
commit
b5d4b17f60
1 changed files with 38 additions and 20 deletions
|
@ -3276,10 +3276,7 @@ impl EditorElement {
|
||||||
accept_keystroke = Some(Keystroke {
|
accept_keystroke = Some(Keystroke {
|
||||||
modifiers: gpui::Modifiers {
|
modifiers: gpui::Modifiers {
|
||||||
alt: true,
|
alt: true,
|
||||||
control: false,
|
..Default::default()
|
||||||
shift: false,
|
|
||||||
platform: false,
|
|
||||||
function: false,
|
|
||||||
},
|
},
|
||||||
key: "tab".to_string(),
|
key: "tab".to_string(),
|
||||||
key_char: None,
|
key_char: None,
|
||||||
|
@ -3291,10 +3288,7 @@ impl EditorElement {
|
||||||
accept_keystroke = Some(Keystroke {
|
accept_keystroke = Some(Keystroke {
|
||||||
modifiers: gpui::Modifiers {
|
modifiers: gpui::Modifiers {
|
||||||
alt: true,
|
alt: true,
|
||||||
control: false,
|
..Default::default()
|
||||||
shift: false,
|
|
||||||
platform: false,
|
|
||||||
function: false,
|
|
||||||
},
|
},
|
||||||
key: "enter".to_string(),
|
key: "enter".to_string(),
|
||||||
key_char: None,
|
key_char: None,
|
||||||
|
@ -3687,12 +3681,13 @@ impl EditorElement {
|
||||||
|
|
||||||
match &active_inline_completion.completion {
|
match &active_inline_completion.completion {
|
||||||
InlineCompletion::Move { target, .. } => {
|
InlineCompletion::Move { target, .. } => {
|
||||||
|
let previewing = false;
|
||||||
let target_display_point = target.to_display_point(editor_snapshot);
|
let target_display_point = target.to_display_point(editor_snapshot);
|
||||||
if target_display_point.row().as_f32() < scroll_top {
|
if target_display_point.row().as_f32() < scroll_top {
|
||||||
let mut element = inline_completion_accept_indicator(
|
let mut element = inline_completion_accept_indicator(
|
||||||
"Jump to Edit",
|
"Jump to Edit",
|
||||||
Some(IconName::ArrowUp),
|
Some(IconName::ArrowUp),
|
||||||
true,
|
previewing,
|
||||||
self.editor.focus_handle(cx),
|
self.editor.focus_handle(cx),
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
|
@ -3705,7 +3700,7 @@ impl EditorElement {
|
||||||
let mut element = inline_completion_accept_indicator(
|
let mut element = inline_completion_accept_indicator(
|
||||||
"Jump to Edit",
|
"Jump to Edit",
|
||||||
Some(IconName::ArrowDown),
|
Some(IconName::ArrowDown),
|
||||||
true,
|
previewing,
|
||||||
self.editor.focus_handle(cx),
|
self.editor.focus_handle(cx),
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
|
@ -3721,7 +3716,7 @@ impl EditorElement {
|
||||||
let mut element = inline_completion_accept_indicator(
|
let mut element = inline_completion_accept_indicator(
|
||||||
"Jump to Edit",
|
"Jump to Edit",
|
||||||
None,
|
None,
|
||||||
true,
|
previewing,
|
||||||
self.editor.focus_handle(cx),
|
self.editor.focus_handle(cx),
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
|
@ -3789,7 +3784,7 @@ impl EditorElement {
|
||||||
let mut element = inline_completion_accept_indicator(
|
let mut element = inline_completion_accept_indicator(
|
||||||
"Accept",
|
"Accept",
|
||||||
None,
|
None,
|
||||||
!previewing,
|
previewing,
|
||||||
self.editor.focus_handle(cx),
|
self.editor.focus_handle(cx),
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
|
@ -5827,17 +5822,40 @@ fn header_jump_data(
|
||||||
fn inline_completion_accept_indicator(
|
fn inline_completion_accept_indicator(
|
||||||
label: impl Into<SharedString>,
|
label: impl Into<SharedString>,
|
||||||
icon: Option<IconName>,
|
icon: Option<IconName>,
|
||||||
show_modifiers: bool,
|
previewing: bool,
|
||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
window: &Window,
|
window: &Window,
|
||||||
cx: &App,
|
cx: &App,
|
||||||
) -> AnyElement {
|
) -> AnyElement {
|
||||||
let bindings = window.bindings_for_action_in(&crate::AcceptInlineCompletion, &focus_handle);
|
let use_hardcoded_linux_preview_binding;
|
||||||
let Some(accept_keystroke) = bindings
|
|
||||||
.last()
|
#[cfg(target_os = "macos")]
|
||||||
.and_then(|binding| binding.keystrokes().first())
|
{
|
||||||
else {
|
use_hardcoded_linux_preview_binding = false;
|
||||||
return div().into_any();
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
{
|
||||||
|
use_hardcoded_linux_preview_binding = previewing;
|
||||||
|
}
|
||||||
|
|
||||||
|
let accept_keystroke = if use_hardcoded_linux_preview_binding {
|
||||||
|
Keystroke {
|
||||||
|
modifiers: Default::default(),
|
||||||
|
key: "enter".to_string(),
|
||||||
|
key_char: None,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let bindings = window.bindings_for_action_in(&crate::AcceptInlineCompletion, &focus_handle);
|
||||||
|
if let Some(keystroke) = bindings
|
||||||
|
.last()
|
||||||
|
.and_then(|binding| binding.keystrokes().first())
|
||||||
|
{
|
||||||
|
// TODO: clone unnecessary once `use_hardcoded_linux_preview_binding` is removed.
|
||||||
|
keystroke.clone()
|
||||||
|
} else {
|
||||||
|
return div().into_any();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let accept_key = h_flex()
|
let accept_key = h_flex()
|
||||||
|
@ -5846,7 +5864,7 @@ fn inline_completion_accept_indicator(
|
||||||
.text_size(TextSize::XSmall.rems(cx))
|
.text_size(TextSize::XSmall.rems(cx))
|
||||||
.text_color(cx.theme().colors().text)
|
.text_color(cx.theme().colors().text)
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.when(show_modifiers, |parent| {
|
.when(!previewing, |parent| {
|
||||||
parent.children(ui::render_modifiers(
|
parent.children(ui::render_modifiers(
|
||||||
&accept_keystroke.modifiers,
|
&accept_keystroke.modifiers,
|
||||||
PlatformStyle::platform(),
|
PlatformStyle::platform(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue