Fix empty title in Recent Projects (#21952)
Close #13595 Release Notes: - Fixed empty title in Recent Projects. --- | Before | After | | --- | --- | | <img width="695" alt="SCR-20241213-nzxr" src="https://github.com/user-attachments/assets/f19a0bad-d542-44cd-85c1-89386d396f27" /> | <img width="625" alt="image" src="https://github.com/user-attachments/assets/0d2afef7-4cd2-43eb-9046-c169df2eb8a0" /> | This is because the `LocalPathsOrder` get empty list. ``` [crates/recent_projects/src/recent_projects.rs:385:9] &location = Local( LocalPaths( [ "/Users/jason/Library/Application Support/Zed/prettier/node_modules", ], ), LocalPathsOrder( [], ), ) [crates/recent_projects/src/recent_projects.rs:386:9] &paths = [ "~/Library/Application Support/Zed/prettier/node_modules", ] [crates/recent_projects/src/recent_projects.rs:385:9] &location = Local( LocalPaths( [ "/Users/jason/github/tree-sitter-csv", ], ), LocalPathsOrder( [], ), ) [crates/recent_projects/src/recent_projects.rs:386:9] &paths = [ "~/github/tree-sitter-csv", ] [crates/recent_projects/src/recent_projects.rs:385:9] &location = Local( LocalPaths( [ "/Users/jason/work/autocorrect/autocorrect-website/dist", ], ), LocalPathsOrder( [], ), ) ```
This commit is contained in:
parent
e08eba8129
commit
dc0075b8e6
5 changed files with 93 additions and 43 deletions
|
@ -1127,22 +1127,14 @@ impl Workspace {
|
|||
.as_ref()
|
||||
.map(|ws| &ws.location)
|
||||
.and_then(|loc| match loc {
|
||||
SerializedWorkspaceLocation::Local(paths, order) => {
|
||||
Some((paths.paths(), order.order()))
|
||||
SerializedWorkspaceLocation::Local(_, order) => {
|
||||
Some((loc.sorted_paths(), order.order()))
|
||||
}
|
||||
_ => None,
|
||||
});
|
||||
|
||||
if let Some((paths, order)) = workspace_location {
|
||||
// todo: should probably move this logic to a method on the SerializedWorkspaceLocation
|
||||
// it's only valid for Local and would be more clear there and be able to be tested
|
||||
// and reused elsewhere
|
||||
paths_to_open = order
|
||||
.iter()
|
||||
.zip(paths.iter())
|
||||
.sorted_by_key(|(i, _)| *i)
|
||||
.map(|(_, path)| path.clone())
|
||||
.collect();
|
||||
paths_to_open = paths.iter().cloned().collect();
|
||||
|
||||
if order.iter().enumerate().any(|(i, &j)| i != j) {
|
||||
project_handle
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue