From 8d3f30c3dba2b983ab0be764826f0c1fe280e79e Mon Sep 17 00:00:00 2001 From: Philipp Mildenberger Date: Sun, 29 May 2022 23:28:06 +0200 Subject: [PATCH] Clear completion in completion() call before filling it with data Because triggering completion at the same cursor position adds the same data again --- helix-term/src/commands.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 762839bad5967..ed85b03f90653 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3622,6 +3622,18 @@ fn remove_primary_selection(cx: &mut Context) { } pub fn completion(cx: &mut Context) { + // TODO completion starts to get ugly... + // maybe think about something like completion provider and separate completion-state into helix-view? + let clear_completion = async move { + let call: job::Callback = + Box::new(move |editor: &mut Editor, compositor: &mut Compositor| { + let ui = compositor.find::().unwrap(); + ui.clear_completion(editor); + }); + Ok(call) + }; + cx.jobs.callback(clear_completion); + use helix_lsp::{lsp, util::pos_to_lsp_pos}; let (view, doc) = current!(cx.editor);