From e5de103728b7a1338056f70524362930695d6c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Fri, 29 Oct 2021 16:48:25 +0900 Subject: [PATCH] Extract a clear_completion method --- helix-term/src/ui/editor.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index bf316ee3..c0d602c7 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -786,6 +786,14 @@ impl EditorView { completion.required_size((size.width, size.height)); self.completion = Some(completion); } + + pub fn clear_completion(&mut self, editor: &mut Editor) { + self.completion = None; + // Clear any savepoints + let (_, doc) = current!(editor); + doc.savepoint = None; + editor.clear_idle_timer(); // don't retrigger + } } impl EditorView { @@ -990,11 +998,7 @@ impl Component for EditorView { if callback.is_some() { // assume close_fn - self.completion = None; - // Clear any savepoints - let (_, doc) = current!(cxt.editor); - doc.savepoint = None; - cxt.editor.clear_idle_timer(); // don't retrigger + self.clear_completion(cxt.editor); } } } @@ -1007,11 +1011,7 @@ impl Component for EditorView { if let Some(completion) = &mut self.completion { completion.update(&mut cxt); if completion.is_empty() { - self.completion = None; - // Clear any savepoints - let (_, doc) = current!(cxt.editor); - doc.savepoint = None; - cxt.editor.clear_idle_timer(); // don't retrigger + self.clear_completion(cxt.editor); } } }