From 4647374449ea8b9ed28dacdf49b95aa6b6fd65a9 Mon Sep 17 00:00:00 2001 From: Rene Leonhardt <65483435+reneleonhardt@users.noreply.github.com> Date: Mon, 7 Jul 2025 10:36:42 +0200 Subject: [PATCH] simplify pickup_last_saved_time --- helix-view/src/document.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 874f84d6e..24003cd95 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -1182,19 +1182,10 @@ impl Document { pub fn pickup_last_saved_time(&mut self) { self.last_saved_time = match self.path() { - Some(path) => match path.metadata() { - Ok(metadata) => match metadata.modified() { - Ok(mtime) => mtime, - Err(err) => { - log::debug!("Could not fetch file system's mtime, falling back to current system time: {}", err); - SystemTime::now() - } - }, - Err(err) => { - log::debug!("Could not fetch file system's mtime, falling back to current system time: {}", err); - SystemTime::now() - } - }, + Some(path) => path.metadata().and_then(|m| m.modified()).unwrap_or_else(|err| { + log::debug!("Could not fetch file system's mtime, falling back to current system time: {}", err); + SystemTime::now() + }), None => SystemTime::now(), }; }