mirror of https://github.com/helix-editor/helix
fix: more nits
parent
a6105af282
commit
2108ec3132
|
@ -2453,7 +2453,7 @@ fn global_search(cx: &mut Context) {
|
||||||
Self {
|
Self {
|
||||||
path: path.to_path_buf(),
|
path: path.to_path_buf(),
|
||||||
line_num,
|
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, .. }| {
|
.with_preview(|_editor, FileResult { path, line_num, .. }| {
|
||||||
Some((path.as_path().into(), Some((*line_num, *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() {
|
if results.is_empty() {
|
||||||
cx.editor.set_status("No matches found");
|
cx.editor.set_status("No matches found");
|
||||||
return;
|
return;
|
||||||
|
@ -2726,7 +2726,7 @@ fn global_refactor(cx: &mut Context) {
|
||||||
let document_type = doc!(cx.editor).document_type.clone();
|
let document_type = doc!(cx.editor).document_type.clone();
|
||||||
|
|
||||||
match &document_type {
|
match &document_type {
|
||||||
helix_view::document::DocumentType::File => return,
|
helix_view::document::DocumentType::File => (),
|
||||||
helix_view::document::DocumentType::Refactor {
|
helix_view::document::DocumentType::Refactor {
|
||||||
matches, line_map, ..
|
matches, line_map, ..
|
||||||
} => {
|
} => {
|
||||||
|
@ -3309,7 +3309,6 @@ fn buffer_picker(cx: &mut Context) {
|
||||||
flags.into()
|
flags.into()
|
||||||
}),
|
}),
|
||||||
PickerColumn::new("path", |meta: &BufferMeta, _| {
|
PickerColumn::new("path", |meta: &BufferMeta, _| {
|
||||||
// TODO: make this rust look like actual rust
|
|
||||||
if meta.is_refactor {
|
if meta.is_refactor {
|
||||||
return REFACTOR_BUFFER_NAME.into();
|
return REFACTOR_BUFFER_NAME.into();
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,7 +266,7 @@ pub struct Picker<T: 'static + Send + Sync, D: 'static> {
|
||||||
/// Given an item in the picker, return the file path and line number to display.
|
/// Given an item in the picker, return the file path and line number to display.
|
||||||
file_fn: Option<FileCallback<T>>,
|
file_fn: Option<FileCallback<T>>,
|
||||||
/// An event handler for syntax highlighting the currently previewed file.
|
/// An event handler for syntax highlighting the currently previewed file.
|
||||||
quickfix_fn: QuickfixCallback<T>,
|
refactor_fn: RefactorCallback<T>,
|
||||||
preview_highlight_handler: Sender<Arc<Path>>,
|
preview_highlight_handler: Sender<Arc<Path>>,
|
||||||
dynamic_query_handler: Option<Sender<DynamicQueryChange>>,
|
dynamic_query_handler: Option<Sender<DynamicQueryChange>>,
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,6 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
|
||||||
primary_column: usize,
|
primary_column: usize,
|
||||||
injector: Injector<T, D>,
|
injector: Injector<T, D>,
|
||||||
callback_fn: impl Fn(&mut Context, &T, Action) + 'static,
|
callback_fn: impl Fn(&mut Context, &T, Action) + 'static,
|
||||||
quickfix_fn: Option<Box<dyn Fn(&mut Context, Vec<&T>) + 'static>>,
|
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self::with(
|
Self::with(
|
||||||
matcher,
|
matcher,
|
||||||
|
@ -384,7 +383,7 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
|
||||||
truncate_start: true,
|
truncate_start: true,
|
||||||
show_preview: true,
|
show_preview: true,
|
||||||
callback_fn: Box::new(callback_fn),
|
callback_fn: Box::new(callback_fn),
|
||||||
quickfix_fn: None,
|
refactor_fn: None,
|
||||||
completion_height: 0,
|
completion_height: 0,
|
||||||
widths,
|
widths,
|
||||||
preview_cache: HashMap::new(),
|
preview_cache: HashMap::new(),
|
||||||
|
@ -422,8 +421,8 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_quickfix(mut self, quickfix_fn: impl Fn(&mut Context, Vec<&T>) + 'static) -> Self {
|
pub fn with_refactor(mut self, quickfix_fn: impl Fn(&mut Context, Vec<&T>) + 'static) -> Self {
|
||||||
self.quickfix_fn = Some(Box::new(quickfix_fn));
|
self.refactor_fn = Some(Box::new(quickfix_fn));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1142,8 +1141,8 @@ impl<I: 'static + Send + Sync, D: 'static + Send + Sync> Component for Picker<I,
|
||||||
self.toggle_preview();
|
self.toggle_preview();
|
||||||
}
|
}
|
||||||
ctrl!('q') => {
|
ctrl!('q') => {
|
||||||
if let Some(_) = self.selection() {
|
if self.selection().is_some() {
|
||||||
if let Some(quickfix) = &self.quickfix_fn {
|
if let Some(quickfix) = &self.refactor_fn {
|
||||||
let items = self.get_list();
|
let items = self.get_list();
|
||||||
(quickfix)(ctx, items);
|
(quickfix)(ctx, items);
|
||||||
}
|
}
|
||||||
|
@ -1194,4 +1193,4 @@ impl<T: 'static + Send + Sync, D> Drop for Picker<T, D> {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PickerCallback<T> = Box<dyn Fn(&mut Context, &T, Action)>;
|
type PickerCallback<T> = Box<dyn Fn(&mut Context, &T, Action)>;
|
||||||
type QuickfixCallback<T> = Option<Box<dyn Fn(&mut Context, Vec<&T>)>>;
|
type RefactorCallback<T> = Option<Box<dyn Fn(&mut Context, Vec<&T>)>>;
|
||||||
|
|
Loading…
Reference in New Issue