Skip to content

Commit

Permalink
Completely remove old Picker and rename FilePicker to Picker
Browse files Browse the repository at this point in the history
  • Loading branch information
sudormrfbin committed Feb 3, 2023
1 parent ba8c647 commit 15b8c3e
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 140 deletions.
10 changes: 5 additions & 5 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use crate::{
compositor::{self, Component, Compositor},
job::Callback,
keymap::ReverseKeymap,
ui::{self, overlay::overlayed, FilePicker, Picker, Popup, Prompt, PromptEvent},
ui::{self, overlay::overlayed, Picker, Popup, Prompt, PromptEvent},
};

use crate::job::{self, Jobs};
Expand Down Expand Up @@ -2084,7 +2084,7 @@ fn global_search(cx: &mut Context) {
return;
}

let picker = FilePicker::with_preview(
let picker = Picker::with_preview(
all_matches,
current_path,
move |cx, FileResult { path, line_num }, action| {
Expand Down Expand Up @@ -2449,7 +2449,7 @@ fn buffer_picker(cx: &mut Context) {
is_current: doc.id() == current,
};

let picker = FilePicker::with_preview(
let picker = Picker::with_preview(
cx.editor
.documents
.values()
Expand Down Expand Up @@ -2527,7 +2527,7 @@ fn jumplist_picker(cx: &mut Context) {
}
};

let picker = FilePicker::with_preview(
let picker = Picker::with_preview(
cx.editor
.tree
.views()
Expand Down Expand Up @@ -2599,7 +2599,7 @@ pub fn command_palette(cx: &mut Context) {
}
}));

let picker = Picker::new(commands, keymap, move |cx, command, _action| {
let picker = Picker::without_preview(commands, keymap, move |cx, command, _action| {
let mut ctx = Context {
register: None,
count: std::num::NonZeroUsize::new(1),
Expand Down
8 changes: 4 additions & 4 deletions helix-term/src/commands/dap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{Context, Editor};
use crate::{
compositor::{self, Compositor},
job::{Callback, Jobs},
ui::{self, overlay::overlayed, FilePicker, Picker, Popup, Prompt, PromptEvent, Text},
ui::{self, overlay::overlayed, Picker, Popup, Prompt, PromptEvent, Text},
};
use dap::{StackFrame, Thread, ThreadStates};
use helix_core::syntax::{DebugArgumentValue, DebugConfigCompletion, DebugTemplate};
Expand Down Expand Up @@ -73,7 +73,7 @@ fn thread_picker(
let debugger = debugger!(editor);

let thread_states = debugger.thread_states.clone();
let picker = FilePicker::with_preview(
let picker = Picker::with_preview(
threads,
thread_states,
move |cx, thread, _action| callback_fn(cx.editor, thread),
Expand Down Expand Up @@ -270,7 +270,7 @@ pub fn dap_launch(cx: &mut Context) {

let templates = config.templates.clone();

cx.push_layer(Box::new(overlayed(Picker::new(
cx.push_layer(Box::new(overlayed(Picker::without_preview(
templates,
(),
|cx, template, _action| {
Expand Down Expand Up @@ -681,7 +681,7 @@ pub fn dap_switch_stack_frame(cx: &mut Context) {

let frames = debugger.stack_frames[&thread_id].clone();

let picker = FilePicker::with_preview(
let picker = Picker::with_preview(
frames,
(),
move |cx, frame, _action| {
Expand Down
14 changes: 7 additions & 7 deletions helix-term/src/commands/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use helix_view::{document::Mode, editor::Action, theme::Style};
use crate::{
compositor::{self, Compositor},
ui::{
self, lsp::SignatureHelp, overlay::overlayed, DynamicPicker, FileLocation, FilePicker,
Popup, PromptEvent,
self, lsp::SignatureHelp, overlay::overlayed, DynamicPicker, FileLocation, Picker, Popup,
PromptEvent,
},
};

Expand Down Expand Up @@ -208,9 +208,9 @@ fn sym_picker(
symbols: Vec<lsp::SymbolInformation>,
current_path: Option<lsp::Url>,
offset_encoding: OffsetEncoding,
) -> FilePicker<lsp::SymbolInformation> {
) -> Picker<lsp::SymbolInformation> {
// TODO: drop current_path comparison and instead use workspace: bool flag?
FilePicker::with_preview(
Picker::with_preview(
symbols,
current_path.clone(),
move |cx, symbol, action| {
Expand Down Expand Up @@ -263,7 +263,7 @@ fn diag_picker(
current_path: Option<lsp::Url>,
format: DiagnosticsFormat,
offset_encoding: OffsetEncoding,
) -> FilePicker<PickerDiagnostic> {
) -> Picker<PickerDiagnostic> {
// TODO: drop current_path comparison and instead use workspace: bool flag?

// flatten the map to a vec of (url, diag) pairs
Expand All @@ -285,7 +285,7 @@ fn diag_picker(
error: cx.editor.theme.get("error"),
};

FilePicker::with_preview(
Picker::with_preview(
flat_diag,
(styles, format),
move |cx, PickerDiagnostic { url, diag }, action| {
Expand Down Expand Up @@ -886,7 +886,7 @@ fn goto_impl(
editor.set_error("No definition found.");
}
_locations => {
let picker = FilePicker::with_preview(
let picker = Picker::with_preview(
locations,
cwdir,
move |cx, location, action| {
Expand Down
7 changes: 4 additions & 3 deletions helix-term/src/commands/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,9 +1159,10 @@ fn lsp_workspace_command(
let callback = async move {
let call: job::Callback = Callback::EditorCompositor(Box::new(
move |_editor: &mut Editor, compositor: &mut Compositor| {
let picker = ui::Picker::new(commands, (), |cx, command, _action| {
execute_lsp_command(cx.editor, command.clone());
});
let picker =
ui::Picker::without_preview(commands, (), |cx, command, _action| {
execute_lsp_command(cx.editor, command.clone());
});
compositor.push(Box::new(overlayed(picker)))
},
));
Expand Down
6 changes: 3 additions & 3 deletions helix-term/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub use completion::Completion;
pub use editor::EditorView;
pub use markdown::Markdown;
pub use menu::Menu;
pub use picker::{DynamicPicker, FileLocation, FilePicker, Picker};
pub use picker::{DynamicPicker, FileLocation, Picker};
pub use popup::Popup;
pub use prompt::{Prompt, PromptEvent};
pub use spinner::{ProgressSpinners, Spinner};
Expand Down Expand Up @@ -157,7 +157,7 @@ pub fn regex_prompt(
cx.push_layer(Box::new(prompt));
}

pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePicker<PathBuf> {
pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> Picker<PathBuf> {
use ignore::{types::TypesBuilder, WalkBuilder};
use std::time::Instant;

Expand Down Expand Up @@ -219,7 +219,7 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi

log::debug!("file_picker init {:?}", Instant::now().duration_since(now));

FilePicker::with_preview(
Picker::with_preview(
files,
root,
move |cx, path: &PathBuf, action| {
Expand Down
Loading

0 comments on commit 15b8c3e

Please sign in to comment.