aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/completion.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/ui/completion.rs')
-rw-r--r--helix-term/src/ui/completion.rs23
1 files changed, 15 insertions, 8 deletions
diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs
index 38005aad..a3637415 100644
--- a/helix-term/src/ui/completion.rs
+++ b/helix-term/src/ui/completion.rs
@@ -2,6 +2,7 @@ use crate::compositor::{Component, Context, EventResult};
use crossterm::event::{Event, KeyCode, KeyEvent};
use helix_view::editor::CompleteAction;
use tui::buffer::Buffer as Surface;
+use tui::text::Spans;
use std::borrow::Cow;
@@ -15,19 +16,25 @@ use helix_lsp::{lsp, util};
use lsp::CompletionItem;
impl menu::Item for CompletionItem {
- fn sort_text(&self) -> &str {
- self.filter_text.as_ref().unwrap_or(&self.label).as_str()
+ type Data = ();
+ fn sort_text(&self, data: &Self::Data) -> Cow<str> {
+ self.filter_text(data)
}
- fn filter_text(&self) -> &str {
- self.filter_text.as_ref().unwrap_or(&self.label).as_str()
+ #[inline]
+ fn filter_text(&self, _data: &Self::Data) -> Cow<str> {
+ self.filter_text
+ .as_ref()
+ .unwrap_or(&self.label)
+ .as_str()
+ .into()
}
- fn label(&self) -> &str {
- self.label.as_str()
+ fn label(&self, _data: &Self::Data) -> Spans {
+ self.label.as_str().into()
}
- fn row(&self) -> menu::Row {
+ fn row(&self, _data: &Self::Data) -> menu::Row {
menu::Row::new(vec![
menu::Cell::from(self.label.as_str()),
menu::Cell::from(match self.kind {
@@ -85,7 +92,7 @@ impl Completion {
start_offset: usize,
trigger_offset: usize,
) -> Self {
- let menu = Menu::new(items, move |editor: &mut Editor, item, event| {
+ let menu = Menu::new(items, (), move |editor: &mut Editor, item, event| {
fn item_to_transaction(
doc: &Document,
item: &CompletionItem,