From 8a33b2b450c2e4d4230804293df2b53db7d10650 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 15 Jan 2025 14:05:18 +0100 Subject: [PATCH] Show loading state for predictions (#23172) Release Notes: - N/A --------- Co-authored-by: Thorsten Co-authored-by: Danilo Leal Co-authored-by: Agus Zubiaga # Conflicts: # crates/editor/src/code_context_menus.rs --- crates/editor/src/code_context_menus.rs | 104 ++++++++++++++++-------- crates/editor/src/editor.rs | 51 +++++++++--- 2 files changed, 113 insertions(+), 42 deletions(-) diff --git a/crates/editor/src/code_context_menus.rs b/crates/editor/src/code_context_menus.rs index 0408d10a203fa35c3ba910144f6655855acd5875..434f94cc39afc4a1e00addaa365de05ff4580877 100644 --- a/crates/editor/src/code_context_menus.rs +++ b/crates/editor/src/code_context_menus.rs @@ -1,8 +1,8 @@ use fuzzy::{StringMatch, StringMatchCandidate}; use gpui::{ - div, px, uniform_list, AnyElement, BackgroundExecutor, Div, FontWeight, ListSizingBehavior, - Model, ScrollStrategy, SharedString, Size, StrikethroughStyle, StyledText, - UniformListScrollHandle, ViewContext, WeakView, + div, pulsating_between, px, uniform_list, Animation, AnimationExt, AnyElement, + BackgroundExecutor, Div, FontWeight, ListSizingBehavior, Model, ScrollStrategy, SharedString, + Size, StrikethroughStyle, StyledText, UniformListScrollHandle, ViewContext, WeakView, }; use language::Buffer; use language::{CodeLabel, Documentation}; @@ -10,6 +10,8 @@ use lsp::LanguageServerId; use multi_buffer::{Anchor, ExcerptId}; use ordered_float::OrderedFloat; use project::{CodeAction, Completion, TaskSourceKind}; +use settings::Settings; +use std::time::Duration; use std::{ cell::RefCell, cmp::{min, Reverse}, @@ -333,9 +335,6 @@ impl CompletionsMenu { entries[0] = hint; } _ => { - if self.selected_item != 0 { - self.selected_item += 1; - } entries.insert(0, hint); } } @@ -463,10 +462,7 @@ impl CompletionsMenu { len } - CompletionEntry::InlineCompletionHint(InlineCompletionMenuHint { - provider_name, - .. - }) => provider_name.len(), + CompletionEntry::InlineCompletionHint(hint) => hint.label().chars().count(), }) .map(|(ix, _)| ix); drop(completions); @@ -490,6 +486,12 @@ impl CompletionsMenu { .enumerate() .map(|(ix, mat)| { let item_ix = start_ix + ix; + let buffer_font = theme::ThemeSettings::get_global(cx).buffer_font.clone(); + let base_label = h_flex() + .gap_1() + .child(div().font(buffer_font.clone()).child("Zed AI")) + .child(div().px_0p5().child("/").opacity(0.2)); + match mat { CompletionEntry::Match(mat) => { let candidate_id = mat.candidate_id; @@ -573,20 +575,57 @@ impl CompletionsMenu { .end_slot::