From 884e7e6750e46c53c99cd07ea3406a6ef516fb1b Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Tue, 26 Aug 2025 12:00:39 -0600 Subject: [PATCH] Filter out rapid changes in active item --- crates/zeta/src/zeta.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/zeta/src/zeta.rs b/crates/zeta/src/zeta.rs index 5303309ab196ed2d91f33475ded0cf8a1590d735..74834a76e717d9657703ec10e2128a35879b749c 100644 --- a/crates/zeta/src/zeta.rs +++ b/crates/zeta/src/zeta.rs @@ -75,6 +75,9 @@ const MAX_EVENT_COUNT: usize = 16; /// Maximum number of recent files to track. const MAX_RECENT_PROJECT_ENTRIES_COUNT: usize = 16; +/// Minimum number of milliseconds between recent project entries to keep them +const MIN_TIME_BETWEEN_RECENT_PROJECT_ENTRIES: Duration = Duration::from_millis(100); + /// Maximum file path length to include in recent files list. const MAX_RECENT_FILE_PATH_LENGTH: usize = 512; @@ -1188,6 +1191,15 @@ and then another { self.recent_project_entries.remove(existing_ix); } + // filter out rapid changes in active item, particularly since this can happen rapidly when + // a workspace is loaded. + if let Some(most_recent) = self.recent_project_entries.back_mut() + && now.duration_since(most_recent.1) > MIN_TIME_BETWEEN_RECENT_PROJECT_ENTRIES + { + most_recent.0 = project_entry_id; + most_recent.1 = now; + return; + } if self.recent_project_entries.len() >= MAX_RECENT_PROJECT_ENTRIES_COUNT { self.recent_project_entries.pop_front(); }