aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/application.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/application.rs')
-rw-r--r--helix-term/src/application.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 6206e6f2..c39a9173 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -199,6 +199,11 @@ impl Application {
self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback);
self.render();
}
+ _ = &mut self.editor.idle_timer => {
+ // idle timeout
+ self.editor.clear_idle_timer();
+ self.handle_idle_timeout();
+ }
}
}
}
@@ -228,6 +233,38 @@ impl Application {
}
}
+ pub fn handle_idle_timeout(&mut self) {
+ use crate::commands::{completion, Context};
+ use helix_view::document::Mode;
+
+ if doc_mut!(self.editor).mode != Mode::Insert {
+ return;
+ }
+ let editor_view = self
+ .compositor
+ .find(std::any::type_name::<ui::EditorView>())
+ .expect("expected at least one EditorView");
+ let editor_view = editor_view
+ .as_any_mut()
+ .downcast_mut::<ui::EditorView>()
+ .unwrap();
+
+ if editor_view.completion.is_some() {
+ return;
+ }
+
+ let mut cx = Context {
+ register: None,
+ editor: &mut self.editor,
+ jobs: &mut self.jobs,
+ count: None,
+ callback: None,
+ on_next_key_callback: None,
+ };
+ completion(&mut cx);
+ self.render();
+ }
+
pub fn handle_terminal_events(&mut self, event: Option<Result<Event, crossterm::ErrorKind>>) {
let mut cx = crate::compositor::Context {
editor: &mut self.editor,