diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ecb72db6..9d3e4f1cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [unreleased] +- Remove the duplicate entries by using the canonicalized file path in `recent_files` provider. + ## [0.54] 2024-5-20 - Fixes the regression of frozen UI caused by the blocking operations in OnMove implementation. #1081 diff --git a/crates/maple_core/src/recent_files.rs b/crates/maple_core/src/recent_files.rs index 70a9f77b5..057012672 100644 --- a/crates/maple_core/src/recent_files.rs +++ b/crates/maple_core/src/recent_files.rs @@ -4,7 +4,7 @@ use matcher::{Bonus, MatcherBuilder}; use rayon::prelude::*; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; -use std::path::Path; +use std::collections::HashSet; use std::sync::Arc; // 3600 seconds @@ -138,13 +138,20 @@ impl SortedRecentFiles { /// /// Used when loading from the disk. pub fn remove_invalid_entries(self) -> Self { + let mut paths = HashSet::new(); Self { entries: self .entries .into_iter() - .filter(|entry| { - let path = Path::new(&entry.fpath); - path.exists() && path.is_file() + .filter_map(|entry| { + let path = std::fs::canonicalize(&entry.fpath).ok()?; + if paths.contains(&path) { + None + } else { + let is_valid_entry = path.exists() && path.is_file(); + paths.insert(path); + is_valid_entry.then_some(entry) + } }) .collect(), ..self diff --git a/crates/maple_core/src/stdio_server/plugin/system.rs b/crates/maple_core/src/stdio_server/plugin/system.rs index b8a170d50..0211be733 100644 --- a/crates/maple_core/src/stdio_server/plugin/system.rs +++ b/crates/maple_core/src/stdio_server/plugin/system.rs @@ -80,7 +80,10 @@ fn parse_vim_which_key_map(config_file: &str) -> HashMap