aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helix-term/src/application.rs33
-rw-r--r--helix-term/src/ui/editor.rs21
2 files changed, 30 insertions, 24 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 2a7c9c21..9f95fa93 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -187,17 +187,13 @@ impl Application {
}
fn render(&mut self) {
- let editor = &mut self.editor;
- let compositor = &mut self.compositor;
- let jobs = &mut self.jobs;
-
let mut cx = crate::compositor::Context {
- editor,
- jobs,
+ editor: &mut self.editor,
+ jobs: &mut self.jobs,
scroll: None,
};
- compositor.render(&mut cx);
+ self.compositor.render(&mut cx);
}
pub async fn event_loop(&mut self) {
@@ -278,31 +274,20 @@ impl Application {
}
pub fn handle_idle_timeout(&mut self) {
- use crate::commands::{insert::idle_completion, Context};
- use helix_view::document::Mode;
-
- if doc!(self.editor).mode != Mode::Insert || !self.config.editor.auto_completion {
- return;
- }
+ use crate::compositor::EventResult;
let editor_view = self
.compositor
.find::<ui::EditorView>()
.expect("expected at least one EditorView");
- if editor_view.completion.is_some() {
- return;
- }
-
- let mut cx = Context {
- register: None,
+ let mut cx = crate::compositor::Context {
editor: &mut self.editor,
jobs: &mut self.jobs,
- count: None,
- callback: None,
- on_next_key_callback: None,
+ scroll: None,
};
- idle_completion(&mut cx);
- self.render();
+ if let EventResult::Consumed(_) = editor_view.handle_idle_timeout(&mut cx) {
+ self.render();
+ }
}
pub fn handle_terminal_events(&mut self, event: Option<Result<Event, crossterm::ErrorKind>>) {
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 {