Skip to content

Commit

Permalink
Fix blank buffer picker preview on doc with no views
Browse files Browse the repository at this point in the history
Reproduction:

* `hx`
* Open any file in a split (`<space>f` and choose anything with `<C-v>`)
* Close the split with `<C-w>q`
* Open up the buffer picker and look the file you opened previously

Previously the preview was empty in this case because the Document's
`selections` hashmap was empty and we returned early, giving `None`
instead of a FileLocation. Instead when the Document is not currently
open in any view we can show the document but with no range highlighted.
  • Loading branch information
the-mikedavis committed Jan 7, 2025
1 parent a0bd39d commit 917174e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3044,12 +3044,11 @@ fn buffer_picker(cx: &mut Context) {
})
.with_preview(|editor, meta| {
let doc = &editor.documents.get(&meta.id)?;
let &view_id = doc.selections().keys().next()?;
let line = doc
.selection(view_id)
.primary()
.cursor_line(doc.text().slice(..));
Some((meta.id.into(), Some((line, line))))
let lines = doc.selections().values().next().map(|selection| {
let cursor_line = selection.primary().cursor_line(doc.text().slice(..));
(cursor_line, cursor_line)
});
Some((meta.id.into(), lines))
});
cx.push_layer(Box::new(overlaid(picker)));
}
Expand Down

0 comments on commit 917174e

Please sign in to comment.