From 82f6f771172e123f1d853a2fe9de0d4dda03e51c Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 27 Nov 2023 11:48:10 -0700 Subject: [PATCH] Use editor's overlay implementation --- crates/editor2/src/editor.rs | 35 +++++++++------------------- crates/ui2/src/components/popover.rs | 4 ++-- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rs index a15d18f030..c713ab085b 100644 --- a/crates/editor2/src/editor.rs +++ b/crates/editor2/src/editor.rs @@ -39,13 +39,12 @@ use futures::FutureExt; use fuzzy::{StringMatch, StringMatchCandidate}; use git::diff_hunk_to_display; use gpui::{ - actions, div, overlay, point, prelude::*, px, relative, rems, size, uniform_list, Action, - AnyElement, AppContext, AsyncWindowContext, BackgroundExecutor, Bounds, ClipboardItem, Context, - ElementId, EventEmitter, FocusHandle, FocusableView, FontFeatures, FontStyle, FontWeight, - HighlightStyle, Hsla, InputHandler, InteractiveText, KeyContext, Model, MouseButton, - ParentElement, Pixels, Render, RenderOnce, SharedString, Styled, StyledText, Subscription, - Task, TextRun, TextStyle, UniformListScrollHandle, View, ViewContext, VisualContext, WeakView, - WhiteSpace, WindowContext, + actions, div, point, prelude::*, px, relative, rems, size, uniform_list, Action, AnyElement, + AppContext, AsyncWindowContext, BackgroundExecutor, Bounds, ClipboardItem, Context, ElementId, + EventEmitter, FocusHandle, FocusableView, FontFeatures, FontStyle, FontWeight, HighlightStyle, + Hsla, InputHandler, InteractiveText, KeyContext, Model, MouseButton, ParentElement, Pixels, + Render, RenderOnce, SharedString, Styled, StyledText, Subscription, Task, TextRun, TextStyle, + UniformListScrollHandle, View, ViewContext, VisualContext, WeakView, WhiteSpace, WindowContext, }; use highlight_matching_bracket::refresh_matching_bracket_highlights; use hover_popover::{hide_hover, HoverState}; @@ -1369,23 +1368,11 @@ impl CompletionsMenu { .track_scroll(self.scroll_handle.clone()) .with_width_from_item(widest_completion_ix); - // Old: - // Popover::new() - // .child(list) - // .when_some(multiline_docs, |popover, multiline_docs| { - // popover.aside(multiline_docs) - // }) - // .into_any_element() - - overlay() - .anchor(gpui::AnchorCorner::TopLeft) - .child( - Popover::new() - .child(list) - .when_some(multiline_docs, |popover, multiline_docs| { - popover.aside(multiline_docs) - }), - ) + Popover::new() + .child(list) + .when_some(multiline_docs, |popover, multiline_docs| { + popover.aside(multiline_docs) + }) .into_any_element() } diff --git a/crates/ui2/src/components/popover.rs b/crates/ui2/src/components/popover.rs index 925fb30a5e..3838e40bec 100644 --- a/crates/ui2/src/components/popover.rs +++ b/crates/ui2/src/components/popover.rs @@ -1,11 +1,11 @@ use gpui::{ - div, AnyElement, Div, Element, ElementId, IntoElement, ParentElement, RenderOnce, Styled, + AnyElement, Div, Element, ElementId, IntoElement, ParentElement, RenderOnce, Styled, WindowContext, }; use smallvec::SmallVec; use theme2::ActiveTheme; -use crate::{h_stack, v_stack, StyledExt}; +use crate::{v_stack, StyledExt}; /// A popover is used to display a menu or show some options. ///