From 6e2aaed5c2cbcedc9ee4e225510cae4f357888aa Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Sat, 2 Jul 2022 16:51:27 +0530 Subject: Reuse menu::Item trait in picker (#2814) * Refactor menu::Item to accomodate external state Will be useful for storing editor state when reused by pickers. * Add some type aliases for readability * Reuse menu::Item trait in picker This opens the way for merging the menu and picker code in the future, since a picker is essentially a menu + prompt. More excitingly, this change will also allow aligning items in the picker, which would be useful (for example) in the command palette for aligning the descriptions to the left and the keybinds to the right in two separate columns. The item formatting of each picker has been kept as is, even though there is room for improvement now that we can format the data into columns, since that is better tackled in a separate PR. * Rename menu::Item::EditorData to Data * Call and inline filter_text() in sort_text() completion * Rename diagnostic picker's Item::Data--- helix-term/src/ui/mod.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'helix-term/src/ui/mod.rs') diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 948a5f2b..8d2bd325 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -23,8 +23,6 @@ pub use text::Text; use helix_core::regex::Regex; use helix_core::regex::RegexBuilder; use helix_view::{Document, Editor, View}; -use tui; -use tui::text::Spans; use std::path::PathBuf; @@ -172,10 +170,7 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi FilePicker::new( files, - move |path: &PathBuf| { - // format_fn - Spans::from(path.strip_prefix(&root).unwrap_or(path).to_string_lossy()) - }, + root, move |cx, path: &PathBuf, action| { if let Err(e) = cx.editor.open(path, action) { let err = if let Some(err) = e.source() { -- cgit v1.2.3-70-g09d2