From 68bad148a58cb580333cc545376b7bc6c2c5abd4 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Wed, 2 Mar 2022 16:10:35 +0900 Subject: Extract idle timeout code into ui/editor.rs --- helix-term/src/ui/editor.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'helix-term/src/ui') diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 9ac72406..3d2e4298 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -856,6 +856,27 @@ impl EditorView { doc.savepoint = None; editor.clear_idle_timer(); // don't retrigger } + + pub fn handle_idle_timeout(&mut self, cx: &mut crate::compositor::Context) -> EventResult { + if self.completion.is_some() + || !cx.editor.config.auto_completion + || doc!(cx.editor).mode != Mode::Insert + { + return EventResult::Ignored(None); + } + + let mut cx = commands::Context { + register: None, + editor: cx.editor, + jobs: cx.jobs, + count: None, + callback: None, + on_next_key_callback: None, + }; + crate::commands::insert::idle_completion(&mut cx); + + EventResult::Consumed(None) + } } impl EditorView { -- cgit v1.2.3-70-g09d2