From 2108ec3132120f696be824c864cf9586c1dbb8b1 Mon Sep 17 00:00:00 2001 From: Gareth Widlansky <101901964+gerblesh@users.noreply.github.com> Date: Mon, 30 Jun 2025 23:08:55 -0700 Subject: [PATCH] fix: more nits --- helix-term/src/commands.rs | 7 +++---- helix-term/src/ui/picker.rs | 15 +++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index e1308231f..d84ec62e1 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2453,7 +2453,7 @@ fn global_search(cx: &mut Context) { Self { path: path.to_path_buf(), line_num, - line_content: line_content.into(), + line_content, } } } @@ -2669,7 +2669,7 @@ fn global_search(cx: &mut Context) { .with_preview(|_editor, FileResult { path, line_num, .. }| { Some((path.as_path().into(), Some((*line_num, *line_num)))) }) - .with_quickfix(move |cx, results: Vec<&FileResult>| { + .with_refactor(move |cx, results: Vec<&FileResult>| { if results.is_empty() { cx.editor.set_status("No matches found"); return; @@ -2726,7 +2726,7 @@ fn global_refactor(cx: &mut Context) { let document_type = doc!(cx.editor).document_type.clone(); match &document_type { - helix_view::document::DocumentType::File => return, + helix_view::document::DocumentType::File => (), helix_view::document::DocumentType::Refactor { matches, line_map, .. } => { @@ -3309,7 +3309,6 @@ fn buffer_picker(cx: &mut Context) { flags.into() }), PickerColumn::new("path", |meta: &BufferMeta, _| { - // TODO: make this rust look like actual rust if meta.is_refactor { return REFACTOR_BUFFER_NAME.into(); } diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 5801fbea6..85465a861 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -266,7 +266,7 @@ pub struct Picker { /// Given an item in the picker, return the file path and line number to display. file_fn: Option>, /// An event handler for syntax highlighting the currently previewed file. - quickfix_fn: QuickfixCallback, + refactor_fn: RefactorCallback, preview_highlight_handler: Sender>, dynamic_query_handler: Option>, } @@ -336,7 +336,6 @@ impl Picker { primary_column: usize, injector: Injector, callback_fn: impl Fn(&mut Context, &T, Action) + 'static, - quickfix_fn: Option) + 'static>>, ) -> Self { Self::with( matcher, @@ -384,7 +383,7 @@ impl Picker { truncate_start: true, show_preview: true, callback_fn: Box::new(callback_fn), - quickfix_fn: None, + refactor_fn: None, completion_height: 0, widths, preview_cache: HashMap::new(), @@ -422,8 +421,8 @@ impl Picker { self } - pub fn with_quickfix(mut self, quickfix_fn: impl Fn(&mut Context, Vec<&T>) + 'static) -> Self { - self.quickfix_fn = Some(Box::new(quickfix_fn)); + pub fn with_refactor(mut self, quickfix_fn: impl Fn(&mut Context, Vec<&T>) + 'static) -> Self { + self.refactor_fn = Some(Box::new(quickfix_fn)); self } @@ -1142,8 +1141,8 @@ impl Component for Picker { - if let Some(_) = self.selection() { - if let Some(quickfix) = &self.quickfix_fn { + if self.selection().is_some() { + if let Some(quickfix) = &self.refactor_fn { let items = self.get_list(); (quickfix)(ctx, items); } @@ -1194,4 +1193,4 @@ impl Drop for Picker { } type PickerCallback = Box; -type QuickfixCallback = Option)>>; +type RefactorCallback = Option)>>;