@SomeoneToIgnore This code should 100% work for future Zed users, but for current Zed users, Zed's internal list of recents may not be synced w/ macOS' Recent Documents at first. If needed this can be fixed by calling `cx.refresh_recent_documents` on startup, but that feels a bit unnecessary. Release Notes: - Fixes behavior of Recent Documents list on macOS
This commit is contained in:
parent
35e1229fbb
commit
30193647f3
9 changed files with 17 additions and 89 deletions
|
@ -13,10 +13,8 @@ path = "src/recent_projects.rs"
|
|||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
collections.workspace = true
|
||||
fuzzy.workspace = true
|
||||
gpui.workspace = true
|
||||
itertools.workspace = true
|
||||
menu.workspace = true
|
||||
ordered-float.workspace = true
|
||||
picker.workspace = true
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
use collections::HashMap;
|
||||
use fuzzy::{StringMatch, StringMatchCandidate};
|
||||
use gpui::{
|
||||
AnyElement, AppContext, DismissEvent, EventEmitter, FocusHandle, FocusableView, Result,
|
||||
Subscription, Task, View, ViewContext, WeakView,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use ordered_float::OrderedFloat;
|
||||
use picker::{
|
||||
highlighted_match_with_paths::{HighlightedMatchWithPaths, HighlightedText},
|
||||
|
@ -431,20 +429,7 @@ impl RecentProjectsDelegate {
|
|||
.recent_workspaces_on_disk()
|
||||
.await
|
||||
.unwrap_or_default();
|
||||
let mut unique_added_paths = HashMap::default();
|
||||
for (id, workspace) in &workspaces {
|
||||
for path in workspace.paths().iter() {
|
||||
unique_added_paths.insert(path.clone(), id);
|
||||
}
|
||||
}
|
||||
let updated_paths = unique_added_paths
|
||||
.into_iter()
|
||||
.sorted_by_key(|(_, id)| *id)
|
||||
.map(|(path, _)| path)
|
||||
.collect::<Vec<_>>();
|
||||
this.update(&mut cx, move |picker, cx| {
|
||||
cx.clear_recent_documents();
|
||||
cx.add_recent_documents(&updated_paths);
|
||||
picker.delegate.workspaces = workspaces;
|
||||
picker.delegate.set_selected_index(ix - 1, cx);
|
||||
picker.delegate.reset_selected_match_index = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue