mirror of
https://github.com/nushell/nushell.git
synced 2024-11-23 00:43:33 +01:00
param completions work now
This commit is contained in:
parent
f9a46ce1e7
commit
b5f8c1cc50
@ -21,6 +21,7 @@ impl NuCompleter {
|
|||||||
let commands: Vec<String> = self.commands.names();
|
let commands: Vec<String> = self.commands.names();
|
||||||
|
|
||||||
let line_chars: Vec<_> = line[..pos].chars().collect();
|
let line_chars: Vec<_> = line[..pos].chars().collect();
|
||||||
|
|
||||||
let mut replace_pos = line_chars.len();
|
let mut replace_pos = line_chars.len();
|
||||||
while replace_pos > 0 {
|
while replace_pos > 0 {
|
||||||
if line_chars[replace_pos - 1] == ' ' {
|
if line_chars[replace_pos - 1] == ' ' {
|
||||||
@ -29,9 +30,11 @@ impl NuCompleter {
|
|||||||
replace_pos -= 1;
|
replace_pos -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we're a flag
|
let substring = line_chars[replace_pos..pos].iter().collect::<String>();
|
||||||
|
|
||||||
let mut completions = vec![];
|
let mut completions = vec![];
|
||||||
|
|
||||||
|
// See if we're a flag
|
||||||
if pos > 0 && line_chars[replace_pos] == '-' {
|
if pos > 0 && line_chars[replace_pos] == '-' {
|
||||||
let mut line_copy = line.to_string();
|
let mut line_copy = line.to_string();
|
||||||
let replace_string = (replace_pos..pos).map(|_| " ").collect::<String>();
|
let replace_string = (replace_pos..pos).map(|_| " ").collect::<String>();
|
||||||
@ -66,10 +69,14 @@ impl NuCompleter {
|
|||||||
{
|
{
|
||||||
if let Some(named) = args.named {
|
if let Some(named) = args.named {
|
||||||
for (name, _) in named.iter() {
|
for (name, _) in named.iter() {
|
||||||
completions.push(rustyline::completion::Pair {
|
let full_flag = format!("--{}", name);
|
||||||
display: format!("--{}", name),
|
|
||||||
replacement: format!("--{}", name),
|
if full_flag.starts_with(&substring) {
|
||||||
});
|
completions.push(rustyline::completion::Pair {
|
||||||
|
display: full_flag.clone(),
|
||||||
|
replacement: full_flag,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user