Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/ui/spinner.rs')
| -rw-r--r-- | helix-term/src/ui/spinner.rs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/helix-term/src/ui/spinner.rs b/helix-term/src/ui/spinner.rs index 9ce61055..e8a43b48 100644 --- a/helix-term/src/ui/spinner.rs +++ b/helix-term/src/ui/spinner.rs @@ -1,19 +1,17 @@ -use std::{collections::HashMap, time::Instant}; - -use helix_lsp::LanguageServerId; +use std::{collections::HashMap, time::SystemTime}; #[derive(Default, Debug)] pub struct ProgressSpinners { - inner: HashMap<LanguageServerId, Spinner>, + inner: HashMap<usize, Spinner>, } impl ProgressSpinners { - pub fn get(&self, id: LanguageServerId) -> Option<&Spinner> { + pub fn get(&self, id: usize) -> Option<&Spinner> { self.inner.get(&id) } - pub fn get_or_create(&mut self, id: LanguageServerId) -> &mut Spinner { - self.inner.entry(id).or_default() + pub fn get_or_create(&mut self, id: usize) -> &mut Spinner { + self.inner.entry(id).or_insert_with(Spinner::default) } } @@ -27,7 +25,7 @@ impl Default for Spinner { pub struct Spinner { frames: Vec<&'static str>, count: usize, - start: Option<Instant>, + start: Option<SystemTime>, interval: u64, } @@ -52,13 +50,14 @@ impl Spinner { } pub fn start(&mut self) { - self.start = Some(Instant::now()); + self.start = Some(SystemTime::now()); } pub fn frame(&self) -> Option<&str> { let idx = (self .start - .map(|time| Instant::now().duration_since(time))? + .map(|time| SystemTime::now().duration_since(time))? + .ok()? .as_millis() / self.interval as u128) as usize % self.count; |