aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-01-06 04:44:29 +0000
committerBlaž Hrastnik2021-01-06 04:44:29 +0000
commit6ec0f8e80f0a39cd19790b8c65ac0c5039a6d46a (patch)
treebc2c68593338acb0c0766be893f07d7a469aff58 /helix-term
parent3cbab2090839ef0d0ca7d7d6ef01404e48ddc8fa (diff)
completion: Don't panic on timeout/no result, just do nothing.
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs52
1 files changed, 28 insertions, 24 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 59490864..1a851413 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -851,31 +851,35 @@ pub fn completion(cx: &mut Context) {
.timeout(Duration::from_secs(2)),
)
.expect("completion failed!")
- .expect("completion failed!");
+ .unwrap_or_default(); // if timeout, just return
+
+ // TODO: if no completion, show some message or something
+ if !res.is_empty() {
+ let picker = ui::Picker::new(
+ res,
+ |item| {
+ // format_fn
+ item.label.as_str().into()
+
+ // TODO: use item.filter_text for filtering
+ },
+ |editor: &mut Editor, item| {
+ // if item.text_edit is Some we use that, else
+ // let insert_text = &item.insert_text.unwrap_or(item.label);
+ // and we insert at position.
+ //
+ // merge this with additional_text_edits
+ },
+ );
- let picker = ui::Picker::new(
- res,
- |item| {
- // format_fn
- item.label.as_str().into()
+ cx.callback = Some(Box::new(
+ move |compositor: &mut Compositor, editor: &mut Editor| {
+ compositor.push(Box::new(picker));
+ },
+ ));
- // TODO: use item.filter_text for filtering
- },
- |editor: &mut Editor, item| {
- // if item.text_edit is Some we use that, else
- // let insert_text = &item.insert_text.unwrap_or(item.label);
- // and we insert at position.
- //
- // merge this with additional_text_edits
- },
- );
+ // TODO!: when iterating over items, show the docs in popup
- cx.callback = Some(Box::new(
- move |compositor: &mut Compositor, editor: &mut Editor| {
- compositor.push(Box::new(picker));
- },
- ));
-
- // TODO: when iterating over items, show the docs in popup
- // language server client needs to be accessible via a registry of some sort
+ // language server client needs to be accessible via a registry of some sort
+ }
}