@@ -9,10 +9,12 @@ use crate::{
9use futures_util::future;
9use futures_util::future;
11 path::{Path, PathBuf},
11 path::{Path, PathBuf},
12 sync::Arc,
13 sync::Arc,
16+use tokio::time::{sleep, Duration, Instant, Sleep};
16use slotmap::SlotMap;
18use slotmap::SlotMap;
18use anyhow::Error;
20use anyhow::Error;
@@ -91,6 +93,8 @@ pub struct Editor {
91 pub status_msg: Option<(String, Severity)>,
93 pub status_msg: Option<(String, Severity)>,
93 pub config: Config,
95 pub config: Config,
97+ pub idle_timer: Pin<Box<Sleep>>,
96#[derive(Debug, Copy, Clone)]
100#[derive(Debug, Copy, Clone)]
@@ -125,10 +129,24 @@ impl Editor {
125 registers: Registers::default(),
129 registers: Registers::default(),
126 clipboard_provider: get_clipboard_provider(),
130 clipboard_provider: get_clipboard_provider(),
127 status_msg: None,
131 status_msg: None,
132+ idle_timer: Box::pin(sleep(Duration::from_millis(500))),
137+ pub fn clear_idle_timer(&mut self) {
138+ // equivalent to internal Instant::far_future() (30 years)
141+ .reset(Instant::now() + Duration::from_secs(86400 * 365 * 30));
144+ pub fn reset_idle_timer(&mut self) {
147+ .reset(Instant::now() + Duration::from_millis(500));
132 pub fn clear_status(&mut self) {
150 pub fn clear_status(&mut self) {
133 self.status_msg = None;
151 self.status_msg = None;