diff options
author | Blaž Hrastnik | 2021-10-29 07:48:25 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-10-29 07:48:41 +0000 |
commit | e5de103728b7a1338056f70524362930695d6c85 (patch) | |
tree | 50eb555df724a0c86c38857cf0e0ff19f2e075fa /helix-term/src | |
parent | 68697cb3322b94b20a47671c50b4fdd143f67ae7 (diff) |
Extract a clear_completion method
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/ui/editor.rs | 20 |
1 files 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); } } } |