diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 4862f8cf8b11a9a68815c69af95aee6465da3dfe..eb83b8b5a0c6adb340ef747d37d86afd815231ac 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -677,8 +677,8 @@ pub struct Editor { show_inline_completions_override: Option, menu_inline_completions_policy: MenuInlineCompletionsPolicy, edit_prediction_preview: EditPredictionPreview, - edit_prediction_cursor_on_leading_whitespace: bool, - edit_prediction_requires_modifier_in_leading_space: bool, + edit_prediction_indent_conflict: bool, + edit_prediction_requires_modifier_in_indent_conflict: bool, inlay_hint_cache: InlayHintCache, next_inlay_id: usize, _subscriptions: Vec, @@ -1403,8 +1403,8 @@ impl Editor { show_inline_completions_override: None, menu_inline_completions_policy: MenuInlineCompletionsPolicy::ByProvider, edit_prediction_settings: EditPredictionSettings::Disabled, - edit_prediction_cursor_on_leading_whitespace: false, - edit_prediction_requires_modifier_in_leading_space: true, + edit_prediction_indent_conflict: false, + edit_prediction_requires_modifier_in_indent_conflict: true, custom_context_menu: None, show_git_blame_gutter: false, show_git_blame_inline: false, @@ -1578,7 +1578,7 @@ impl Editor { || self.edit_prediction_requires_modifier() // Require modifier key when the cursor is on leading whitespace, to allow `tab` // bindings to insert tab characters. - || (self.edit_prediction_requires_modifier_in_leading_space && self.edit_prediction_cursor_on_leading_whitespace) + || (self.edit_prediction_requires_modifier_in_indent_conflict && self.edit_prediction_indent_conflict) } pub fn accept_edit_prediction_keybind( @@ -2150,7 +2150,7 @@ impl Editor { self.refresh_selected_text_highlights(window, cx); refresh_matching_bracket_highlights(self, window, cx); self.update_visible_inline_completion(window, cx); - self.edit_prediction_requires_modifier_in_leading_space = true; + self.edit_prediction_requires_modifier_in_indent_conflict = true; linked_editing_ranges::refresh_linked_ranges(self, window, cx); if self.git_blame_inline_enabled { self.start_inline_blame_timer(window, cx); @@ -5136,7 +5136,7 @@ impl Editor { } } - self.edit_prediction_requires_modifier_in_leading_space = false; + self.edit_prediction_requires_modifier_in_indent_conflict = false; } pub fn accept_partial_inline_completion( @@ -5434,8 +5434,19 @@ impl Editor { self.edit_prediction_settings = self.edit_prediction_settings_at_position(&buffer, cursor_buffer_position, cx); - self.edit_prediction_cursor_on_leading_whitespace = - multibuffer.is_line_whitespace_upto(cursor); + self.edit_prediction_indent_conflict = multibuffer.is_line_whitespace_upto(cursor); + + if self.edit_prediction_indent_conflict { + let cursor_point = cursor.to_point(&multibuffer); + + let indents = multibuffer.suggested_indents(cursor_point.row..cursor_point.row + 1, cx); + + if let Some((_, indent)) = indents.iter().next() { + if indent.len == cursor_point.column { + self.edit_prediction_indent_conflict = false; + } + } + } let inline_completion = provider.suggest(&buffer, cursor_buffer_position, cx)?; let edits = inline_completion