aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-22 04:16:56 +0000
committerBlaž Hrastnik2021-03-22 04:16:56 +0000
commit698e4ddea46e9c94d537c8e4a6c69e7dc9ee1947 (patch)
tree5411ea3186d1a1481776ad4d84af38cd5a0c595f /helix-term/src/ui
parentcbcacb1063c9b6384867a6078a75595ae2ff6861 (diff)
clippy: Factor out a Completion type.
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/mod.rs5
-rw-r--r--helix-term/src/ui/prompt.rs8
2 files changed, 8 insertions, 5 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index b35cba60..ca133b66 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -137,9 +137,10 @@ pub fn buffer_picker(views: &[View], current: usize) -> Picker<(Option<PathBuf>,
}
pub mod completers {
- use std::{borrow::Cow, ops::RangeFrom};
+ use crate::ui::prompt::Completion;
+ use std::borrow::Cow;
// TODO: we could return an iter/lazy thing so it can fetch as many as it needs.
- pub fn filename(input: &str) -> Vec<(RangeFrom<usize>, Cow<'static, str>)> {
+ pub fn filename(input: &str) -> Vec<Completion> {
// Rust's filename handling is really annoying.
use ignore::WalkBuilder;
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs
index db691f50..8b3a1ca2 100644
--- a/helix-term/src/ui/prompt.rs
+++ b/helix-term/src/ui/prompt.rs
@@ -4,13 +4,15 @@ use helix_core::Position;
use helix_view::{Editor, Theme};
use std::{borrow::Cow, ops::RangeFrom};
+pub type Completion = (RangeFrom<usize>, Cow<'static, str>);
+
pub struct Prompt {
prompt: String,
pub line: String,
cursor: usize,
- completion: Vec<(RangeFrom<usize>, Cow<'static, str>)>,
+ completion: Vec<Completion>,
completion_selection_index: Option<usize>,
- completion_fn: Box<dyn FnMut(&str) -> Vec<(RangeFrom<usize>, Cow<'static, str>)>>,
+ completion_fn: Box<dyn FnMut(&str) -> Vec<Completion>>,
callback_fn: Box<dyn FnMut(&mut Editor, &str, PromptEvent)>,
}
@@ -27,7 +29,7 @@ pub enum PromptEvent {
impl Prompt {
pub fn new(
prompt: String,
- mut completion_fn: impl FnMut(&str) -> Vec<(RangeFrom<usize>, Cow<'static, str>)> + 'static,
+ mut completion_fn: impl FnMut(&str) -> Vec<Completion> + 'static,
callback_fn: impl FnMut(&mut Editor, &str, PromptEvent) + 'static,
) -> Prompt {
Prompt {