zeta: Always show ghost text, even if showing completion in menu (#22194)

See:
![screenshot-2024-12-18-17 26
22@2x](https://github.com/user-attachments/assets/82bdea76-6c96-4c4d-a08a-1601381a378f)


https://github.com/user-attachments/assets/165d9f0d-8339-4fd9-a796-a67121689af6



Release Notes:

- N/A

Co-authored-by: Danilo <danilo@zed.dev>
This commit is contained in:
Thorsten Ball 2024-12-19 10:00:58 +01:00 committed by GitHub
parent b93cee8d27
commit 2a17274ec2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 40 deletions

View file

@ -575,7 +575,7 @@ impl CompletionsMenu {
} }
CompletionEntry::InlineCompletionHint(hint) => match &hint.text { CompletionEntry::InlineCompletionHint(hint) => match &hint.text {
InlineCompletionText::Edit { text, highlights } => div() InlineCompletionText::Edit { text, highlights } => div()
.my_1() .mx_1()
.rounded(px(6.)) .rounded(px(6.))
.bg(cx.theme().colors().editor_background) .bg(cx.theme().colors().editor_background)
.border_1() .border_1()
@ -594,7 +594,7 @@ impl CompletionsMenu {
multiline_docs multiline_docs
.id("multiline_docs") .id("multiline_docs")
.max_h(max_height) .max_h(max_height)
.px_0p5() .px_2()
.min_w(px(260.)) .min_w(px(260.))
.max_w(MAX_COMPLETIONS_ASIDE_WIDTH) .max_w(MAX_COMPLETIONS_ASIDE_WIDTH)
.overflow_y_scroll() .overflow_y_scroll()

View file

@ -3746,7 +3746,6 @@ impl Editor {
if editor.show_inline_completions_in_menu(cx) { if editor.show_inline_completions_in_menu(cx) {
if let Some(hint) = editor.inline_completion_menu_hint(cx) { if let Some(hint) = editor.inline_completion_menu_hint(cx) {
editor.hide_active_inline_completion(cx);
menu.show_inline_completion_hint(hint); menu.show_inline_completion_hint(hint);
} }
} else { } else {
@ -4711,17 +4710,6 @@ impl Editor {
Some(active_inline_completion.completion) Some(active_inline_completion.completion)
} }
fn hide_active_inline_completion(&mut self, cx: &mut ViewContext<Self>) {
if let Some(active_inline_completion) = self.active_inline_completion.as_ref() {
self.splice_inlays(
active_inline_completion.inlay_ids.clone(),
Default::default(),
cx,
);
self.clear_highlights::<InlineCompletionHighlight>(cx);
}
}
fn update_visible_inline_completion(&mut self, cx: &mut ViewContext<Self>) -> Option<()> { fn update_visible_inline_completion(&mut self, cx: &mut ViewContext<Self>) -> Option<()> {
let selection = self.selections.newest_anchor(); let selection = self.selections.newest_anchor();
let cursor = selection.head(); let cursor = selection.head();
@ -4791,7 +4779,6 @@ impl Editor {
invalidation_row_range = edit_start_row..cursor_row; invalidation_row_range = edit_start_row..cursor_row;
completion = InlineCompletion::Move(first_edit_start); completion = InlineCompletion::Move(first_edit_start);
} else { } else {
if !self.show_inline_completions_in_menu(cx) || !self.has_active_completions_menu() {
if edits if edits
.iter() .iter()
.all(|(range, _)| range.to_offset(&multibuffer).is_empty()) .all(|(range, _)| range.to_offset(&multibuffer).is_empty())
@ -4819,7 +4806,6 @@ impl Editor {
cx, cx,
); );
} }
}
invalidation_row_range = edit_start_row..edit_end_row; invalidation_row_range = edit_start_row..edit_end_row;
completion = InlineCompletion::Edit(edits); completion = InlineCompletion::Edit(edits);