Skip to content

Commit

Permalink
Refine the completion popover
Browse files Browse the repository at this point in the history
  • Loading branch information
danilo-leal committed Dec 17, 2024
1 parent 0b50672 commit d1b0dfc
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions crates/editor/src/code_context_menus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ use lsp::LanguageServerId;
use multi_buffer::{Anchor, ExcerptId};
use ordered_float::OrderedFloat;
use project::{CodeAction, Completion, TaskSourceKind};
use settings::Settings;
use task::ResolvedTask;
use ui::{
h_flex, ActiveTheme as _, Color, FluentBuilder as _, InteractiveElement as _, IntoElement,
Label, LabelCommon as _, LabelSize, ListItem, ParentElement as _, Popover,
StatefulInteractiveElement as _, Styled, Toggleable as _,
};
use theme::ThemeSettings;
use ui::{prelude::*, Color, IntoElement, ListItem, Popover, Styled};
use util::ResultExt as _;
use workspace::Workspace;

Expand Down Expand Up @@ -425,8 +423,10 @@ impl CompletionsMenu {
CompletionEntry::InlineCompletionHint(hint) => Some(match &hint.text {
InlineCompletionText::Edit { text, highlights } => div()
.my_1()
.rounded_md()
.rounded(px(6.))
.bg(cx.theme().colors().editor_background)
.border_1()
.border_color(cx.theme().colors().border_variant)
.child(
gpui::StyledText::new(text.clone())
.with_highlights(&style.text, highlights.clone()),
Expand All @@ -451,9 +451,8 @@ impl CompletionsMenu {
.flex_1()
.px_1p5()
.py_1()
.min_w(px(260.))
.max_w(px(640.))
.w(px(500.))
.w(px(450.))
.overflow_y_scroll()
.occlude()
});
Expand Down Expand Up @@ -513,6 +512,7 @@ impl CompletionsMenu {
(range, highlight)
}),
);

let completion_label =
StyledText::new(completion.label.text.clone())
.with_highlights(&style.text, highlights);
Expand Down Expand Up @@ -559,25 +559,27 @@ impl CompletionsMenu {
CompletionEntry::InlineCompletionHint(InlineCompletionMenuHint {
provider_name,
..
}) => div()
.min_w(px(250.))
.max_w(px(500.))
.pb_1()
.border_b_1()
.border_color(cx.theme().colors().border_variant)
.child(
ListItem::new("inline-completion")
.inset(true)
.toggle_state(item_ix == selected_item)
.on_click(cx.listener(move |editor, _event, cx| {
cx.stop_propagation();
editor.accept_inline_completion(
&AcceptInlineCompletion {},
cx,
);
}))
.child(Label::new(SharedString::new_static(provider_name))),
),
}) => div().min_w(px(250.)).max_w(px(500.)).child(
ListItem::new("inline-completion")
.inset(true)
.toggle_state(item_ix == selected_item)
.start_slot(Icon::new(IconName::ZedPredict))
.child(
div()
.font(ThemeSettings::get_global(cx).buffer_font.clone())
.child(format!(
"{} Completion",
SharedString::new_static(provider_name)
)),
)
.on_click(cx.listener(move |editor, _event, cx| {
cx.stop_propagation();
editor.accept_inline_completion(
&AcceptInlineCompletion {},
cx,
);
})),
),
}
})
.collect()
Expand Down

0 comments on commit d1b0dfc

Please sign in to comment.