From 89e027f61eda0d918ee2c2622f6ad370a76c5754 Mon Sep 17 00:00:00 2001 From: Jonas Maier <> Date: Tue, 17 Mar 2026 15:32:30 +0100 Subject: completion when using path in place of command --- src/parse/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/parse') 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, (ParseError, &[u8])> { } } -#[derive(Debug)] +#[derive(Debug, PartialEq)] pub enum CompletionKind { Command, + PathCommand, Argument, Variable, None, @@ -840,7 +841,7 @@ impl Ast { } impl ExpString { - fn completion(&self, e: &mut E, kind: CompletionKind) -> CompletionContext { + fn completion(&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() -- cgit v1.2.3