From cd16df19c1f951e1ef0c560ae5e084b18bd2c713 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Wed, 23 Dec 2020 17:03:20 +0900 Subject: lsp: generate_transaction_from_text_edits --- helix-term/src/commands.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'helix-term/src') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index eb23041c..862cf312 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -837,17 +837,32 @@ pub fn completion(cx: &mut Context) { let language_server = cx.language_servers.get("rust", &cx.executor).unwrap(); use log::info; + use smol_timeout::TimeoutExt; + use std::time::Duration; + // TODO: blocking here is not ideal - let res = smol::block_on(language_server.completion(&cx.view.doc)).expect("completion failed!"); + let res = smol::block_on( + language_server + .completion(&cx.view.doc) + .timeout(Duration::from_secs(2)), + ) + .expect("completion failed!") + .expect("completion failed!"); 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 }, ); -- cgit v1.2.3-70-g09d2