Checkpoint - try using overlay for completions popover
[no ci]
This commit is contained in:
parent
1acc6b462f
commit
8a35a02863
3 changed files with 34 additions and 23 deletions
|
@ -39,12 +39,13 @@ use futures::FutureExt;
|
||||||
use fuzzy::{StringMatch, StringMatchCandidate};
|
use fuzzy::{StringMatch, StringMatchCandidate};
|
||||||
use git::diff_hunk_to_display;
|
use git::diff_hunk_to_display;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, div, point, prelude::*, px, relative, rems, size, uniform_list, Action, AnyElement,
|
actions, div, overlay, point, prelude::*, px, relative, rems, size, uniform_list, Action,
|
||||||
AppContext, AsyncWindowContext, BackgroundExecutor, Bounds, ClipboardItem, Context, ElementId,
|
AnyElement, AppContext, AsyncWindowContext, BackgroundExecutor, Bounds, ClipboardItem, Context,
|
||||||
EventEmitter, FocusHandle, FocusableView, FontFeatures, FontStyle, FontWeight, HighlightStyle,
|
ElementId, EventEmitter, FocusHandle, FocusableView, FontFeatures, FontStyle, FontWeight,
|
||||||
Hsla, InputHandler, InteractiveText, KeyContext, Model, MouseButton, ParentElement, Pixels,
|
HighlightStyle, Hsla, InputHandler, InteractiveText, KeyContext, Model, MouseButton,
|
||||||
Render, RenderOnce, SharedString, Styled, StyledText, Subscription, Task, TextRun, TextStyle,
|
ParentElement, Pixels, Render, RenderOnce, SharedString, Styled, StyledText, Subscription,
|
||||||
UniformListScrollHandle, View, ViewContext, VisualContext, WeakView, WhiteSpace, WindowContext,
|
Task, TextRun, TextStyle, UniformListScrollHandle, View, ViewContext, VisualContext, WeakView,
|
||||||
|
WhiteSpace, WindowContext,
|
||||||
};
|
};
|
||||||
use highlight_matching_bracket::refresh_matching_bracket_highlights;
|
use highlight_matching_bracket::refresh_matching_bracket_highlights;
|
||||||
use hover_popover::{hide_hover, HoverState};
|
use hover_popover::{hide_hover, HoverState};
|
||||||
|
@ -1335,7 +1336,7 @@ impl CompletionsMenu {
|
||||||
div()
|
div()
|
||||||
.id(mat.candidate_id)
|
.id(mat.candidate_id)
|
||||||
.min_w(px(220.))
|
.min_w(px(220.))
|
||||||
.max_w(px(640.))
|
.max_w(px(540.))
|
||||||
.whitespace_nowrap()
|
.whitespace_nowrap()
|
||||||
.overflow_hidden()
|
.overflow_hidden()
|
||||||
.text_ui()
|
.text_ui()
|
||||||
|
@ -1370,11 +1371,23 @@ impl CompletionsMenu {
|
||||||
.track_scroll(self.scroll_handle.clone())
|
.track_scroll(self.scroll_handle.clone())
|
||||||
.with_width_from_item(widest_completion_ix);
|
.with_width_from_item(widest_completion_ix);
|
||||||
|
|
||||||
Popover::new()
|
// Old:
|
||||||
.child(list)
|
// Popover::new()
|
||||||
.when_some(multiline_docs, |popover, multiline_docs| {
|
// .child(list)
|
||||||
popover.aside(multiline_docs)
|
// .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)
|
||||||
|
}),
|
||||||
|
)
|
||||||
.into_any_element()
|
.into_any_element()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ impl Element for Overlay {
|
||||||
origin: Point::zero(),
|
origin: Point::zero(),
|
||||||
size: cx.viewport_size(),
|
size: cx.viewport_size(),
|
||||||
};
|
};
|
||||||
|
dbg!(limits);
|
||||||
|
|
||||||
match self.fit_mode {
|
match self.fit_mode {
|
||||||
OverlayFitMode::SnapToWindow => {
|
OverlayFitMode::SnapToWindow => {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use gpui::{
|
use gpui::{
|
||||||
AnyElement, Div, Element, ElementId, IntoElement, ParentElement, RenderOnce, Styled,
|
div, AnyElement, Div, Element, ElementId, IntoElement, ParentElement, RenderOnce, Styled,
|
||||||
WindowContext,
|
WindowContext,
|
||||||
};
|
};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use theme2::ActiveTheme;
|
use theme2::ActiveTheme;
|
||||||
|
|
||||||
use crate::{v_stack, StyledExt};
|
use crate::{h_stack, v_stack, StyledExt};
|
||||||
|
|
||||||
/// A popover is used to display a menu or show some options.
|
/// A popover is used to display a menu or show some options.
|
||||||
///
|
///
|
||||||
|
@ -44,21 +44,18 @@ impl RenderOnce for Popover {
|
||||||
type Rendered = Div;
|
type Rendered = Div;
|
||||||
|
|
||||||
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
fn render(self, cx: &mut WindowContext) -> Self::Rendered {
|
||||||
v_stack()
|
div()
|
||||||
.relative()
|
.flex()
|
||||||
.elevation_2(cx)
|
.flex_none()
|
||||||
.p_1()
|
.gap_1()
|
||||||
.children(self.children)
|
.child(v_stack().elevation_2(cx).p_1().children(self.children))
|
||||||
.when_some(self.aside, |this, aside| {
|
.when_some(self.aside, |this, aside| {
|
||||||
// TODO: This will statically position the aside to the top right of the popover.
|
// TODO: This will statically position the aside to the top right of the popover.
|
||||||
// We should update this to use gpui2::overlay avoid collisions with the window edges.
|
// We should update this to use gpui2::overlay avoid collisions with the window edges.
|
||||||
this.child(
|
this.child(
|
||||||
v_stack()
|
v_stack()
|
||||||
.top_0()
|
|
||||||
.left_full()
|
|
||||||
.ml_1()
|
|
||||||
.absolute()
|
|
||||||
.elevation_2(cx)
|
.elevation_2(cx)
|
||||||
|
.flex_1()
|
||||||
.bg(cx.theme().colors().surface_background)
|
.bg(cx.theme().colors().surface_background)
|
||||||
.p_1()
|
.p_1()
|
||||||
.child(aside),
|
.child(aside),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue