Extract a clear_completion method
This commit is contained in:
parent
68697cb332
commit
e5de103728
@ -786,6 +786,14 @@ pub fn set_completion(
|
|||||||
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 @@ fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
|
|||||||
|
|
||||||
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 @@ fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
|
|||||||
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…
Reference in New Issue
Block a user