Skip to content

Commit

Permalink
wip: rebased on master and fixed truncated icon in file picker
Browse files Browse the repository at this point in the history
  • Loading branch information
lazytanuki committed Nov 16, 2022
1 parent 40ed6f7 commit 89a346c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion helix-term/src/commands/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ pub fn code_action(cx: &mut Context) {

impl ui::menu::Item for lsp::Command {
type Data = ();
fn label(&self, _data: &Self::Data) -> Spans {
fn label_text(&self, _data: &Self::Data) -> Spans {
self.title.as_str().into()
}
}
Expand Down
2 changes: 1 addition & 1 deletion helix-term/src/ui/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub trait Item {
let icon_span = icons.and_then(|icons| self.icon(icons));
let mut spans = self.label_text(data);
if let Some(icon_span) = icon_span {
spans.0.push(icon_span.into());
spans.0.insert(0, icon_span.into());
}
spans
}
Expand Down
4 changes: 3 additions & 1 deletion helix-term/src/ui/picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ impl<T: Item + 'static> Component for Picker<T> {
.fuzzy_indicies(&String::from(&spans), &self.matcher)
.unwrap_or_default();

let mut first_span = true;
spans.0.into_iter().fold(inner, |pos, span| {
let new_x = surface
.set_string_truncated(
Expand All @@ -670,9 +671,10 @@ impl<T: Item + 'static> Component for Picker<T> {
}
},
true,
self.truncate_start,
self.truncate_start && (!first_span && icons_enabled),
)
.0;
first_span = false;
pos.clip_left(new_x - pos.x)
});
}
Expand Down

0 comments on commit 89a346c

Please sign in to comment.