mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 12:54:42 +00:00
Increase outline picker max height (#3831)
This PR increases the max height of the outline picker so that it can take up a larger area of the screen when there are lots of results. This behavior is similar to the way it was in Zed1. Release Notes: - N/A
This commit is contained in:
parent
c6d9bc5a16
commit
f5b60adcf9
2 changed files with 14 additions and 3 deletions
|
@ -79,8 +79,12 @@ impl OutlineView {
|
||||||
editor: View<Editor>,
|
editor: View<Editor>,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> OutlineView {
|
) -> OutlineView {
|
||||||
|
const MAX_HEIGHT_IN_VH: f32 = 0.75;
|
||||||
|
|
||||||
let delegate = OutlineViewDelegate::new(cx.view().downgrade(), outline, editor, cx);
|
let delegate = OutlineViewDelegate::new(cx.view().downgrade(), outline, editor, cx);
|
||||||
let picker = cx.new_view(|cx| Picker::new(delegate, cx));
|
let picker = cx.new_view(|cx| {
|
||||||
|
Picker::new(delegate, cx).max_height(cx.viewport_size().height * MAX_HEIGHT_IN_VH)
|
||||||
|
});
|
||||||
OutlineView { picker }
|
OutlineView { picker }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ pub struct Picker<D: PickerDelegate> {
|
||||||
pending_update_matches: Option<Task<()>>,
|
pending_update_matches: Option<Task<()>>,
|
||||||
confirm_on_update: Option<bool>,
|
confirm_on_update: Option<bool>,
|
||||||
width: Option<Length>,
|
width: Option<Length>,
|
||||||
|
max_height: Option<Length>,
|
||||||
|
|
||||||
/// Whether the `Picker` is rendered as a self-contained modal.
|
/// Whether the `Picker` is rendered as a self-contained modal.
|
||||||
///
|
///
|
||||||
|
@ -72,6 +73,7 @@ impl<D: PickerDelegate> Picker<D> {
|
||||||
pending_update_matches: None,
|
pending_update_matches: None,
|
||||||
confirm_on_update: None,
|
confirm_on_update: None,
|
||||||
width: None,
|
width: None,
|
||||||
|
max_height: None,
|
||||||
is_modal: true,
|
is_modal: true,
|
||||||
};
|
};
|
||||||
this.update_matches("".to_string(), cx);
|
this.update_matches("".to_string(), cx);
|
||||||
|
@ -83,6 +85,11 @@ impl<D: PickerDelegate> Picker<D> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn max_height(mut self, max_height: impl Into<gpui::Length>) -> Self {
|
||||||
|
self.max_height = Some(max_height.into());
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn modal(mut self, modal: bool) -> Self {
|
pub fn modal(mut self, modal: bool) -> Self {
|
||||||
self.is_modal = modal;
|
self.is_modal = modal;
|
||||||
self
|
self
|
||||||
|
@ -260,6 +267,8 @@ impl<D: PickerDelegate> Render for Picker<D> {
|
||||||
v_stack()
|
v_stack()
|
||||||
.flex_grow()
|
.flex_grow()
|
||||||
.py_2()
|
.py_2()
|
||||||
|
.max_h(self.max_height.unwrap_or(rems(18.).into()))
|
||||||
|
.overflow_hidden()
|
||||||
.children(self.delegate.render_header(cx))
|
.children(self.delegate.render_header(cx))
|
||||||
.child(
|
.child(
|
||||||
uniform_list(
|
uniform_list(
|
||||||
|
@ -296,8 +305,6 @@ impl<D: PickerDelegate> Render for Picker<D> {
|
||||||
.track_scroll(self.scroll_handle.clone())
|
.track_scroll(self.scroll_handle.clone())
|
||||||
)
|
)
|
||||||
|
|
||||||
.max_h_72()
|
|
||||||
.overflow_hidden(),
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.when(self.delegate.match_count() == 0, |el| {
|
.when(self.delegate.match_count() == 0, |el| {
|
||||||
|
|
Loading…
Reference in a new issue