Signature improves, sorted completions (#545)

This commit is contained in:
JT
2021-12-22 07:50:18 +11:00
committed by GitHub
parent 3ad5d4af66
commit 266fac910a
3 changed files with 74 additions and 33 deletions

View File

@ -18,10 +18,8 @@ impl NuCompleter {
pub fn new(engine_state: EngineState) -> Self {
Self { engine_state }
}
}
impl Completer for NuCompleter {
fn complete(&self, line: &str, pos: usize) -> Vec<(reedline::Span, String)> {
fn completion_helper(&self, line: &str, pos: usize) -> Vec<(reedline::Span, String)> {
let mut working_set = StateWorkingSet::new(&self.engine_state);
let offset = working_set.next_span_start();
let pos = offset + pos;
@ -201,6 +199,16 @@ impl Completer for NuCompleter {
}
}
impl Completer for NuCompleter {
fn complete(&self, line: &str, pos: usize) -> Vec<(reedline::Span, String)> {
let mut output = self.completion_helper(line, pos);
output.sort_by(|a, b| a.1.cmp(&b.1));
output
}
}
fn file_path_completion(
span: nu_protocol::Span,
partial: &str,