diff options
Diffstat (limited to 'src/parse')
| -rw-r--r-- | src/parse/mod.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs index e085f34..006fce2 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -1,4 +1,4 @@ -use crate::BString; +use crate::{BString, run::CommandKind}; #[cfg(test)] mod test; @@ -797,9 +797,10 @@ pub fn do_parse(x: &[u8]) -> Res<Ast<PreExpansion>, (ParseError, &[u8])> { } } -#[derive(Debug)] +#[derive(Debug, PartialEq)] pub enum CompletionKind { Command, + PathCommand, Argument, Variable, None, @@ -840,7 +841,7 @@ impl Ast<PreExpansion> { } impl ExpString { - fn completion<E: Expander>(&self, e: &mut E, kind: CompletionKind) -> CompletionContext { + fn completion<E: Expander>(&self, e: &mut E, mut kind: CompletionKind) -> CompletionContext { if let Some(StringPart::Var(var)) = self.parts.last() && !var.already_complete { @@ -853,6 +854,9 @@ impl ExpString { { cmd.cmd.completion(e) } else if let Ok(s) = self.clone().expand(e) { + if s.contains(&b'/') && kind == CompletionKind::Command { + kind = CompletionKind::PathCommand; + } CompletionContext { kind, partial: s } } else { CompletionContext::none() |
