Remove Completer.get_sort_by()
This commit is contained in:
parent
bd071f11f7
commit
2dd0963c44
|
@ -1,4 +1,4 @@
|
|||
use crate::completions::{CompletionOptions, SortBy};
|
||||
use crate::completions::CompletionOptions;
|
||||
use nu_protocol::{
|
||||
engine::{Stack, StateWorkingSet},
|
||||
Span,
|
||||
|
@ -19,10 +19,6 @@ pub trait Completer {
|
|||
pos: usize,
|
||||
options: &CompletionOptions,
|
||||
) -> Vec<SemanticSuggestion>;
|
||||
|
||||
fn get_sort_by(&self) -> SortBy {
|
||||
SortBy::Ascending
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, PartialEq)]
|
||||
|
|
|
@ -201,7 +201,7 @@ impl Completer for CommandCompletion {
|
|||
return sort_suggestions(
|
||||
&String::from_utf8_lossy(&prefix),
|
||||
subcommands,
|
||||
self.get_sort_by(),
|
||||
SortBy::Ascending,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -230,13 +230,9 @@ impl Completer for CommandCompletion {
|
|||
sort_suggestions(
|
||||
&String::from_utf8_lossy(&prefix),
|
||||
commands,
|
||||
self.get_sort_by(),
|
||||
SortBy::LevenshteinDistance,
|
||||
)
|
||||
}
|
||||
|
||||
fn get_sort_by(&self) -> SortBy {
|
||||
SortBy::LevenshteinDistance
|
||||
}
|
||||
}
|
||||
|
||||
pub fn find_non_whitespace_index(contents: &[u8], start: usize) -> usize {
|
||||
|
|
|
@ -129,15 +129,7 @@ impl Completer for CustomCompletion {
|
|||
} else {
|
||||
filter(&prefix, suggestions, completion_options)
|
||||
};
|
||||
sort_suggestions(
|
||||
&String::from_utf8_lossy(&prefix),
|
||||
suggestions,
|
||||
self.get_sort_by(),
|
||||
)
|
||||
}
|
||||
|
||||
fn get_sort_by(&self) -> SortBy {
|
||||
self.sort_by
|
||||
sort_suggestions(&String::from_utf8_lossy(&prefix), suggestions, self.sort_by)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::completions::{file_path_completion, Completer, CompletionOptions, SortBy};
|
||||
use crate::completions::{file_path_completion, Completer, CompletionOptions};
|
||||
use nu_protocol::{
|
||||
engine::{Stack, StateWorkingSet},
|
||||
Span,
|
||||
|
@ -133,8 +133,4 @@ impl Completer for DotNuCompletion {
|
|||
|
||||
output
|
||||
}
|
||||
|
||||
fn get_sort_by(&self) -> SortBy {
|
||||
SortBy::LevenshteinDistance
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
use crate::completions::{completion_common::sort_suggestions, Completer, CompletionOptions};
|
||||
use crate::completions::{
|
||||
completion_common::sort_suggestions, Completer, CompletionOptions, SortBy,
|
||||
};
|
||||
use nu_protocol::{
|
||||
ast::{Expr, Expression},
|
||||
engine::{Stack, StateWorkingSet},
|
||||
|
@ -90,11 +92,7 @@ impl Completer for FlagCompletion {
|
|||
}
|
||||
}
|
||||
|
||||
return sort_suggestions(
|
||||
&String::from_utf8_lossy(&prefix),
|
||||
output,
|
||||
self.get_sort_by(),
|
||||
);
|
||||
return sort_suggestions(&String::from_utf8_lossy(&prefix), output, SortBy::Ascending);
|
||||
}
|
||||
|
||||
vec![]
|
||||
|
|
|
@ -9,7 +9,9 @@ use nu_protocol::{
|
|||
use reedline::Suggestion;
|
||||
use std::str;
|
||||
|
||||
use super::completion_common::sort_suggestions;
|
||||
use super::{completion_common::sort_suggestions, SortBy};
|
||||
|
||||
const SORT_BY: SortBy = SortBy::Ascending;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct VariableCompletion {
|
||||
|
@ -72,7 +74,7 @@ impl Completer for VariableCompletion {
|
|||
}
|
||||
}
|
||||
|
||||
return sort_suggestions(&prefix_str, output, self.get_sort_by());
|
||||
return sort_suggestions(&prefix_str, output, SORT_BY);
|
||||
}
|
||||
} else {
|
||||
// No nesting provided, return all env vars
|
||||
|
@ -96,7 +98,7 @@ impl Completer for VariableCompletion {
|
|||
}
|
||||
}
|
||||
|
||||
return sort_suggestions(&prefix_str, output, self.get_sort_by());
|
||||
return sort_suggestions(&prefix_str, output, SORT_BY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +122,7 @@ impl Completer for VariableCompletion {
|
|||
}
|
||||
}
|
||||
|
||||
return sort_suggestions(&prefix_str, output, self.get_sort_by());
|
||||
return sort_suggestions(&prefix_str, output, SORT_BY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,7 +144,7 @@ impl Completer for VariableCompletion {
|
|||
}
|
||||
}
|
||||
|
||||
return sort_suggestions(&prefix_str, output, self.get_sort_by());
|
||||
return sort_suggestions(&prefix_str, output, SORT_BY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user