From 698e4ddea46e9c94d537c8e4a6c69e7dc9ee1947 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Mon, 22 Mar 2021 13:16:56 +0900 Subject: clippy: Factor out a Completion type. --- helix-term/src/ui/mod.rs | 5 +++-- helix-term/src/ui/prompt.rs | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'helix-term/src/ui') 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, } 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, Cow<'static, str>)> { + pub fn filename(input: &str) -> Vec { // 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, Cow<'static, str>); + pub struct Prompt { prompt: String, pub line: String, cursor: usize, - completion: Vec<(RangeFrom, Cow<'static, str>)>, + completion: Vec, completion_selection_index: Option, - completion_fn: Box Vec<(RangeFrom, Cow<'static, str>)>>, + completion_fn: Box Vec>, callback_fn: Box, } @@ -27,7 +29,7 @@ pub enum PromptEvent { impl Prompt { pub fn new( prompt: String, - mut completion_fn: impl FnMut(&str) -> Vec<(RangeFrom, Cow<'static, str>)> + 'static, + mut completion_fn: impl FnMut(&str) -> Vec + 'static, callback_fn: impl FnMut(&mut Editor, &str, PromptEvent) + 'static, ) -> Prompt { Prompt { -- cgit v1.2.3-70-g09d2