Skip to content

Commit

Permalink
Update CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchengxu committed May 25, 2024
1 parent 18d36ea commit 90ada17
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions crates/maple_core/src/recent_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion crates/maple_core/src/stdio_server/plugin/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ fn parse_vim_which_key_map(config_file: &str) -> HashMap<char, HashMap<char, Str
fn note_recent_file(file_path: String) {
tracing::debug!(?file_path, "Received a recent file notification");

let path = std::path::Path::new(&file_path);
let Ok(path) = std::fs::canonicalize(&file_path) else {
return;
};

if !path.exists() || !path.is_file() {
return;
}
Expand Down

0 comments on commit 90ada17

Please sign in to comment.