Render completion menu items using ListItem
s
This commit is contained in:
parent
ae71d1ad5d
commit
ce5855da2f
1 changed files with 14 additions and 28 deletions
|
@ -98,7 +98,9 @@ pub use sum_tree::Bias;
|
||||||
use sum_tree::TreeMap;
|
use sum_tree::TreeMap;
|
||||||
use text::{OffsetUtf16, Rope};
|
use text::{OffsetUtf16, Rope};
|
||||||
use theme::{ActiveTheme, DiagnosticStyle, PlayerColor, SyntaxTheme, ThemeColors, ThemeSettings};
|
use theme::{ActiveTheme, DiagnosticStyle, PlayerColor, SyntaxTheme, ThemeColors, ThemeSettings};
|
||||||
use ui::{h_stack, ButtonSize, ButtonStyle, Icon, IconButton, List, Popover, Tooltip};
|
use ui::{
|
||||||
|
h_stack, ButtonSize, ButtonStyle, Icon, IconButton, ListItem, ListItemSpacing, Popover, Tooltip,
|
||||||
|
};
|
||||||
use ui::{prelude::*, IconSize};
|
use ui::{prelude::*, IconSize};
|
||||||
use util::{post_inc, RangeExt, ResultExt, TryFutureExt};
|
use util::{post_inc, RangeExt, ResultExt, TryFutureExt};
|
||||||
use workspace::{searchable::SearchEvent, ItemNavHistory, Pane, SplitDirection, ViewId, Workspace};
|
use workspace::{searchable::SearchEvent, ItemNavHistory, Pane, SplitDirection, ViewId, Workspace};
|
||||||
|
@ -1243,34 +1245,18 @@ impl CompletionsMenu {
|
||||||
if text.trim().is_empty() {
|
if text.trim().is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(
|
Some(h_stack().ml_2().child(Label::new(text.clone())))
|
||||||
h_stack()
|
|
||||||
.flex_grow()
|
|
||||||
.child(div().flex_grow())
|
|
||||||
.child(Label::new(text.clone())),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
h_stack()
|
div().min_w(px(220.)).max_w(px(540.)).child(
|
||||||
.id(mat.candidate_id)
|
ListItem::new(mat.candidate_id)
|
||||||
.w(px(540.))
|
.inset(true)
|
||||||
.whitespace_nowrap()
|
.spacing(ListItemSpacing::Sparse)
|
||||||
.overflow_hidden()
|
.selected(item_ix == selected_item)
|
||||||
.text_ui()
|
.on_click(cx.listener(move |editor, _event, cx| {
|
||||||
.gap_2()
|
|
||||||
.px_1()
|
|
||||||
.rounded(px(4.))
|
|
||||||
.bg(cx.theme().colors().ghost_element_background)
|
|
||||||
.hover(|style| style.bg(cx.theme().colors().ghost_element_hover))
|
|
||||||
.when(item_ix == selected_item, |div| {
|
|
||||||
div.bg(cx.theme().colors().ghost_element_selected)
|
|
||||||
})
|
|
||||||
.on_mouse_down(
|
|
||||||
MouseButton::Left,
|
|
||||||
cx.listener(move |editor, _event, cx| {
|
|
||||||
cx.stop_propagation();
|
cx.stop_propagation();
|
||||||
editor
|
editor
|
||||||
.confirm_completion(
|
.confirm_completion(
|
||||||
|
@ -1280,10 +1266,10 @@ impl CompletionsMenu {
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
.map(|task| task.detach_and_log_err(cx));
|
.map(|task| task.detach_and_log_err(cx));
|
||||||
}),
|
}))
|
||||||
)
|
.child(div().text_ui().child(completion_label))
|
||||||
.child(completion_label)
|
.end_slot::<Div>(documentation_label),
|
||||||
.children(documentation_label)
|
)
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue