From 1bcb624ae65273cad13a3a65c567e0850fb0c9ed Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Tue, 8 Feb 2022 18:48:19 +0900 Subject: Instant is more suitable than SystemTime for spinners --- helix-term/src/ui/spinner.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'helix-term') diff --git a/helix-term/src/ui/spinner.rs b/helix-term/src/ui/spinner.rs index e8a43b48..68965469 100644 --- a/helix-term/src/ui/spinner.rs +++ b/helix-term/src/ui/spinner.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, time::SystemTime}; +use std::{collections::HashMap, time::Instant}; #[derive(Default, Debug)] pub struct ProgressSpinners { @@ -25,7 +25,7 @@ impl Default for Spinner { pub struct Spinner { frames: Vec<&'static str>, count: usize, - start: Option, + start: Option, interval: u64, } @@ -50,14 +50,13 @@ impl Spinner { } pub fn start(&mut self) { - self.start = Some(SystemTime::now()); + self.start = Some(Instant::now()); } pub fn frame(&self) -> Option<&str> { let idx = (self .start - .map(|time| SystemTime::now().duration_since(time))? - .ok()? + .map(|time| Instant::now().duration_since(time))? .as_millis() / self.interval as u128) as usize % self.count; -- cgit v1.2.3-70-g09d2