edit predictions: Do not require modifier if in leading space but just accepted a prediction (#24733)
This makes the tab tab tab experience smoother Release Notes: - N/A --------- Co-authored-by: Antonio Scandurra <me@as-cii.com> Co-authored-by: as-cii <as-cii@zed.dev> Co-authored-by: Danilo Leal <daniloleal09@gmail.com> Co-authored-by: Antonio <antonio@zed.dev> Co-authored-by: Ben <ben@zed.dev>
This commit is contained in:
parent
3f95d79fc5
commit
553cc2cca5
2 changed files with 20 additions and 16 deletions
|
@ -709,11 +709,12 @@ pub struct Editor {
|
||||||
/// Used to prevent flickering as the user types while the menu is open
|
/// Used to prevent flickering as the user types while the menu is open
|
||||||
stale_inline_completion_in_menu: Option<InlineCompletionState>,
|
stale_inline_completion_in_menu: Option<InlineCompletionState>,
|
||||||
edit_prediction_settings: EditPredictionSettings,
|
edit_prediction_settings: EditPredictionSettings,
|
||||||
edit_prediction_cursor_on_leading_whitespace: bool,
|
|
||||||
inline_completions_hidden_for_vim_mode: bool,
|
inline_completions_hidden_for_vim_mode: bool,
|
||||||
show_inline_completions_override: Option<bool>,
|
show_inline_completions_override: Option<bool>,
|
||||||
menu_inline_completions_policy: MenuInlineCompletionsPolicy,
|
menu_inline_completions_policy: MenuInlineCompletionsPolicy,
|
||||||
edit_prediction_preview: EditPredictionPreview,
|
edit_prediction_preview: EditPredictionPreview,
|
||||||
|
edit_prediction_cursor_on_leading_whitespace: bool,
|
||||||
|
edit_prediction_requires_modifier_in_leading_space: bool,
|
||||||
inlay_hint_cache: InlayHintCache,
|
inlay_hint_cache: InlayHintCache,
|
||||||
next_inlay_id: usize,
|
next_inlay_id: usize,
|
||||||
_subscriptions: Vec<Subscription>,
|
_subscriptions: Vec<Subscription>,
|
||||||
|
@ -1425,6 +1426,7 @@ impl Editor {
|
||||||
menu_inline_completions_policy: MenuInlineCompletionsPolicy::ByProvider,
|
menu_inline_completions_policy: MenuInlineCompletionsPolicy::ByProvider,
|
||||||
edit_prediction_settings: EditPredictionSettings::Disabled,
|
edit_prediction_settings: EditPredictionSettings::Disabled,
|
||||||
edit_prediction_cursor_on_leading_whitespace: false,
|
edit_prediction_cursor_on_leading_whitespace: false,
|
||||||
|
edit_prediction_requires_modifier_in_leading_space: true,
|
||||||
custom_context_menu: None,
|
custom_context_menu: None,
|
||||||
show_git_blame_gutter: false,
|
show_git_blame_gutter: false,
|
||||||
show_git_blame_inline: false,
|
show_git_blame_inline: false,
|
||||||
|
@ -1573,7 +1575,7 @@ impl Editor {
|
||||||
|| self.edit_prediction_requires_modifier()
|
|| self.edit_prediction_requires_modifier()
|
||||||
// Require modifier key when the cursor is on leading whitespace, to allow `tab`
|
// Require modifier key when the cursor is on leading whitespace, to allow `tab`
|
||||||
// bindings to insert tab characters.
|
// bindings to insert tab characters.
|
||||||
|| self.edit_prediction_cursor_on_leading_whitespace
|
|| (self.edit_prediction_requires_modifier_in_leading_space && self.edit_prediction_cursor_on_leading_whitespace)
|
||||||
{
|
{
|
||||||
key_context.add(EDIT_PREDICTION_REQUIRES_MODIFIER_KEY_CONTEXT);
|
key_context.add(EDIT_PREDICTION_REQUIRES_MODIFIER_KEY_CONTEXT);
|
||||||
}
|
}
|
||||||
|
@ -2137,6 +2139,7 @@ impl Editor {
|
||||||
self.refresh_document_highlights(cx);
|
self.refresh_document_highlights(cx);
|
||||||
refresh_matching_bracket_highlights(self, window, cx);
|
refresh_matching_bracket_highlights(self, window, cx);
|
||||||
self.update_visible_inline_completion(window, cx);
|
self.update_visible_inline_completion(window, cx);
|
||||||
|
self.edit_prediction_requires_modifier_in_leading_space = true;
|
||||||
linked_editing_ranges::refresh_linked_ranges(self, window, cx);
|
linked_editing_ranges::refresh_linked_ranges(self, window, cx);
|
||||||
if self.git_blame_inline_enabled {
|
if self.git_blame_inline_enabled {
|
||||||
self.start_inline_blame_timer(window, cx);
|
self.start_inline_blame_timer(window, cx);
|
||||||
|
@ -5013,6 +5016,8 @@ impl Editor {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.edit_prediction_requires_modifier_in_leading_space = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn accept_partial_inline_completion(
|
pub fn accept_partial_inline_completion(
|
||||||
|
@ -5662,19 +5667,17 @@ impl Editor {
|
||||||
.bg(bg_color)
|
.bg(bg_color)
|
||||||
.font(theme::ThemeSettings::get_global(cx).buffer_font.clone())
|
.font(theme::ThemeSettings::get_global(cx).buffer_font.clone())
|
||||||
.text_size(TextSize::XSmall.rems(cx))
|
.text_size(TextSize::XSmall.rems(cx))
|
||||||
.when(!self.edit_prediction_preview_is_active(), |parent| {
|
.children(ui::render_modifiers(
|
||||||
parent.children(ui::render_modifiers(
|
&accept_keystroke.modifiers,
|
||||||
&accept_keystroke.modifiers,
|
PlatformStyle::platform(),
|
||||||
PlatformStyle::platform(),
|
Some(if accept_keystroke.modifiers == window.modifiers() {
|
||||||
Some(if accept_keystroke.modifiers == window.modifiers() {
|
Color::Accent
|
||||||
Color::Accent
|
} else {
|
||||||
} else {
|
Color::Muted
|
||||||
Color::Muted
|
}),
|
||||||
}),
|
Some(IconSize::XSmall.rems().into()),
|
||||||
Some(IconSize::XSmall.rems().into()),
|
false,
|
||||||
false,
|
))
|
||||||
))
|
|
||||||
})
|
|
||||||
.child(accept_keystroke.key.clone())
|
.child(accept_keystroke.key.clone())
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
|
@ -3811,13 +3811,13 @@ impl EditorElement {
|
||||||
|
|
||||||
let mut element = v_flex()
|
let mut element = v_flex()
|
||||||
.items_end()
|
.items_end()
|
||||||
.shadow_sm()
|
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.h(ACCEPT_INDICATOR_HEIGHT)
|
.h(ACCEPT_INDICATOR_HEIGHT)
|
||||||
.mb(px(-1.))
|
.mb(px(-1.))
|
||||||
.px_1p5()
|
.px_1p5()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
|
.shadow_sm()
|
||||||
.bg(Editor::edit_prediction_line_popover_bg_color(cx))
|
.bg(Editor::edit_prediction_line_popover_bg_color(cx))
|
||||||
.border_1()
|
.border_1()
|
||||||
.border_b_0()
|
.border_b_0()
|
||||||
|
@ -3829,6 +3829,7 @@ impl EditorElement {
|
||||||
div()
|
div()
|
||||||
.bg(cx.theme().colors().editor_background)
|
.bg(cx.theme().colors().editor_background)
|
||||||
.border_1()
|
.border_1()
|
||||||
|
.shadow_sm()
|
||||||
.border_color(cx.theme().colors().border)
|
.border_color(cx.theme().colors().border)
|
||||||
.rounded_lg()
|
.rounded_lg()
|
||||||
.rounded_tr(Pixels::ZERO)
|
.rounded_tr(Pixels::ZERO)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue