Rename 'default' option to 'smart'
This commit is contained in:
parent
786a6acb79
commit
617608711c
|
@ -320,7 +320,7 @@ pub fn sort_completions<T>(
|
||||||
get_value: fn(&T) -> &str,
|
get_value: fn(&T) -> &str,
|
||||||
) -> Vec<T> {
|
) -> Vec<T> {
|
||||||
// Sort items
|
// Sort items
|
||||||
if options.sort == CompletionSort::Default && options.match_algorithm == MatchAlgorithm::Fuzzy {
|
if options.sort == CompletionSort::Smart && options.match_algorithm == MatchAlgorithm::Fuzzy {
|
||||||
let mut matcher = SkimMatcherV2::default();
|
let mut matcher = SkimMatcherV2::default();
|
||||||
if options.case_sensitive {
|
if options.case_sensitive {
|
||||||
matcher = matcher.respect_case();
|
matcher = matcher.respect_case();
|
||||||
|
|
|
@ -111,7 +111,7 @@ impl Completer for CustomCompletion {
|
||||||
sort: if should_sort {
|
sort: if should_sort {
|
||||||
CompletionSort::Alphabetical
|
CompletionSort::Alphabetical
|
||||||
} else {
|
} else {
|
||||||
CompletionSort::Default
|
CompletionSort::Smart
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -788,8 +788,8 @@ fn subcommand_completions(mut subcommand_completer: NuCompleter) {
|
||||||
let prefix = "foo br";
|
let prefix = "foo br";
|
||||||
let suggestions = subcommand_completer.complete(prefix, prefix.len());
|
let suggestions = subcommand_completer.complete(prefix, prefix.len());
|
||||||
match_suggestions(
|
match_suggestions(
|
||||||
vec!["foo bar".to_string(), "foo aabcrr".to_string()],
|
&vec!["foo bar".to_string(), "foo aabcrr".to_string()],
|
||||||
suggestions,
|
&suggestions,
|
||||||
);
|
);
|
||||||
|
|
||||||
let prefix = "foo b";
|
let prefix = "foo b";
|
||||||
|
@ -1290,8 +1290,8 @@ fn sort_fuzzy_completions_in_alphabetical_order(mut fuzzy_alpha_sort_completer:
|
||||||
// Even though "nushell" is a better match, it should come second because
|
// Even though "nushell" is a better match, it should come second because
|
||||||
// the completions should be sorted in alphabetical order
|
// the completions should be sorted in alphabetical order
|
||||||
match_suggestions(
|
match_suggestions(
|
||||||
vec!["custom_completion.nu".into(), "nushell".into()],
|
&vec!["custom_completion.nu".into(), "nushell".into()],
|
||||||
suggestions,
|
&suggestions,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ impl ReconstructVal for CompletionAlgorithm {
|
||||||
#[derive(Serialize, Deserialize, Clone, Copy, Debug, Default, PartialEq)]
|
#[derive(Serialize, Deserialize, Clone, Copy, Debug, Default, PartialEq)]
|
||||||
pub enum CompletionSort {
|
pub enum CompletionSort {
|
||||||
#[default]
|
#[default]
|
||||||
Default,
|
Smart,
|
||||||
Alphabetical,
|
Alphabetical,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,9 +47,9 @@ impl FromStr for CompletionSort {
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
match s.to_ascii_lowercase().as_str() {
|
match s.to_ascii_lowercase().as_str() {
|
||||||
"default" => Ok(Self::Default),
|
"smart" => Ok(Self::Smart),
|
||||||
"alphabetical" => Ok(Self::Alphabetical),
|
"alphabetical" => Ok(Self::Alphabetical),
|
||||||
_ => Err("expected either 'default' or 'alpha'"),
|
_ => Err("expected either 'smart' or 'alphabetical'"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ impl FromStr for CompletionSort {
|
||||||
impl ReconstructVal for CompletionSort {
|
impl ReconstructVal for CompletionSort {
|
||||||
fn reconstruct_value(&self, span: Span) -> Value {
|
fn reconstruct_value(&self, span: Span) -> Value {
|
||||||
let str = match self {
|
let str = match self {
|
||||||
Self::Default => "default",
|
Self::Smart => "smart",
|
||||||
Self::Alphabetical => "alphabetical",
|
Self::Alphabetical => "alphabetical",
|
||||||
};
|
};
|
||||||
Value::string(str, span)
|
Value::string(str, span)
|
||||||
|
|
|
@ -206,7 +206,7 @@ $env.config = {
|
||||||
quick: true # set this to false to prevent auto-selecting completions when only one remains
|
quick: true # set this to false to prevent auto-selecting completions when only one remains
|
||||||
partial: true # set this to false to prevent partial filling of the prompt
|
partial: true # set this to false to prevent partial filling of the prompt
|
||||||
algorithm: "prefix" # prefix or fuzzy
|
algorithm: "prefix" # prefix or fuzzy
|
||||||
sort: "default" # "default" (choose based on algorithm) or "alphabetical"
|
sort: "smart" # "smart" (alphabetical for prefix matching, fuzzy score for fuzzy matching) or "alphabetical"
|
||||||
external: {
|
external: {
|
||||||
enable: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up may be very slow
|
enable: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up may be very slow
|
||||||
max_results: 100 # setting it lower can improve completion performance at the cost of omitting some options
|
max_results: 100 # setting it lower can improve completion performance at the cost of omitting some options
|
||||||
|
|
Loading…
Reference in New Issue
Block a user