diff options
Diffstat (limited to 'src/parse/mod.rs')
| -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() |
