diff options
| author | Jonas Maier <> | 2026-03-10 16:37:07 +0100 |
|---|---|---|
| committer | Jonas Maier <> | 2026-03-10 16:37:07 +0100 |
| commit | 1bab9e3ed54476d0b4a47da84693a2e4e50effc6 (patch) | |
| tree | cc0fb5a4dd85a28e23766972b1fccdce8a93d9c5 /src/main.rs | |
| parent | 5a20456be99899e6519ec0595817e0d436eab627 (diff) | |
| download | pish-1bab9e3ed54476d0b4a47da84693a2e4e50effc6.tar.gz | |
variable completion
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/src/main.rs b/src/main.rs index 37d2ed3..6012a86 100644 --- a/src/main.rs +++ b/src/main.rs @@ -355,37 +355,39 @@ fn event_loop() { &cmd, &mut Executor::new_for_completion(session.clone()), ); - let mut se = session.lock().unwrap(); - match comp.kind { + + let suggestions = match comp.kind { parse::CompletionKind::Command => todo!(), - parse::CompletionKind::Argument => { - let suggestions = completion::path_completion(comp.partial); - if suggestions.len() == 0 { - continue; - } + parse::CompletionKind::Argument => completion::path_completion(comp.partial), + parse::CompletionKind::Variable => { + completion::variable_completion(session.clone(), comp.partial) + } + parse::CompletionKind::None => continue, + }; - if suggestions.len() == 1 { - // apply suggestion - se.type_bytes(&suggestions[0].delta); - continue; - } + if suggestions.len() == 0 { + continue; + } - cursor::save(); + let mut se = session.lock().unwrap(); - // one line below - print!("\r\n"); - for s in suggestions { - io::stdout().lock().write_all(&s.display).unwrap(); - println!(); - } + if suggestions.len() == 1 { + // apply suggestion + se.type_bytes(&suggestions[0].delta); + continue; + } - cursor::restore(); - stdout.lock().flush().unwrap(); - } - parse::CompletionKind::None => { - se.type_bytes(b" "); - } + cursor::save(); + + // one line below + print!("\r\n"); + for s in suggestions { + io::stdout().lock().write_all(&s.display).unwrap(); + println!(); } + + cursor::restore(); + stdout.lock().flush().unwrap(); } // Escape sequence |
