Skip to content

Commit

Permalink
Extract a clear_completion method
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Oct 29, 2021
1 parent 68697cb commit e5de103
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
}
}
Expand All @@ -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);
}
}
}
Expand Down

0 comments on commit e5de103

Please sign in to comment.