diff options
| author | Jonas Maier <> | 2026-03-10 13:13:49 +0100 |
|---|---|---|
| committer | Jonas Maier <> | 2026-03-10 13:13:49 +0100 |
| commit | 7728b844958bb7882ddf384b40e5711d7a9316ad (patch) | |
| tree | fd8ecf5981da5cb317a2328265fad88a24b80093 /src/parse | |
| parent | 961314b443849840e15d079ebd5724383489fd05 (diff) | |
| download | pish-7728b844958bb7882ddf384b40e5711d7a9316ad.tar.gz | |
completion if there is variables in the to-be-completed string
Diffstat (limited to 'src/parse')
| -rw-r--r-- | src/parse/mod.rs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs index f08426e..47e2d87 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -704,27 +704,23 @@ impl CompletionContext { } } -fn expstr_cc(s: &ExpString, kind: CompletionKind) -> CompletionContext { - if s.parts.len() > 1 || !s.parts[0].is_boring() { - CompletionContext::none() - } else { - CompletionContext { - kind, - partial: s.parts[0].clone().unwrap_boring().clone(), - } +fn expstr_cc<E: Expander>(s: &ExpString, kind: CompletionKind, e: &mut E) -> CompletionContext { + match s.clone().expand(e) { + Ok(buf) => CompletionContext { kind, partial: buf }, + Err(_) => CompletionContext::none(), } } -pub fn completion_context<'a>(x: &'a [u8]) -> CompletionContext { +pub fn completion_context<'a, E: Expander>(x: &'a [u8], e: &mut E) -> CompletionContext { let mut cursor = Cursor::new(x, ParseMode::Completion); let ast = Ast::parse(&mut cursor); match ast { Ok(Ast::Pipes(pipes)) if cursor.spaced == false => { if let Some(cmd) = pipes.cmds.last() { if cmd.args.is_empty() { - expstr_cc(&cmd.cmd, CompletionKind::Command) + expstr_cc(&cmd.cmd, CompletionKind::Command, e) } else { - expstr_cc(&cmd.args[cmd.args.len() - 1], CompletionKind::Argument) + expstr_cc(&cmd.args[cmd.args.len() - 1], CompletionKind::Argument, e) } } else { CompletionContext::none() |
