Extract a clear_completion method

imgbot
Blaž Hrastnik 3 years ago
parent 68697cb332
commit e5de103728

@ -786,6 +786,14 @@ impl EditorView {
completion.required_size((size.width, size.height)); completion.required_size((size.width, size.height));
self.completion = Some(completion); 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 { impl EditorView {
@ -990,11 +998,7 @@ impl Component for EditorView {
if callback.is_some() { if callback.is_some() {
// assume close_fn // assume close_fn
self.completion = None; self.clear_completion(cxt.editor);
// Clear any savepoints
let (_, doc) = current!(cxt.editor);
doc.savepoint = None;
cxt.editor.clear_idle_timer(); // don't retrigger
} }
} }
} }
@ -1007,11 +1011,7 @@ impl Component for EditorView {
if let Some(completion) = &mut self.completion { if let Some(completion) = &mut self.completion {
completion.update(&mut cxt); completion.update(&mut cxt);
if completion.is_empty() { if completion.is_empty() {
self.completion = None; self.clear_completion(cxt.editor);
// Clear any savepoints
let (_, doc) = current!(cxt.editor);
doc.savepoint = None;
cxt.editor.clear_idle_timer(); // don't retrigger
} }
} }
} }

Loading…
Cancel
Save