R3.1: real paths without \?\ on Windows (dunce); old recent lists read plain
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
1066b41cb0
commit
d0b5aede95
21 files changed
+59
-24
No files matched your search
@@ -137,7 +137,7 @@ impl Host for Desk {
|
||||
view.update(cx, |view, cx| view.moved(folder.to_path_buf(), cx));
|
||||
}
|
||||
self.track_recent(id, &path, cx);
|
||||
let real = std::fs::canonicalize(&path).ok();
|
||||
let real = dunce::canonicalize(&path).ok();
|
||||
if self
|
||||
.going
|
||||
.as_ref()
|
||||
|
||||
@@ -75,10 +75,11 @@ fn a_file_opens_with_its_outline_and_joins_the_recent_list(cx: &mut TestAppConte
|
||||
4,
|
||||
"the jump lands"
|
||||
);
|
||||
let real = std::fs::canonicalize(&path).expect("real");
|
||||
let real = dunce::canonicalize(&path).expect("real");
|
||||
assert!(desk.read_with(cx, |desk, _| desk.recent.contains(&real)));
|
||||
let kept = std::fs::read_to_string(data.path().join("recent.json")).expect("the list");
|
||||
assert!(kept.contains("a.md"), "{kept}");
|
||||
assert!(!kept.contains(r"\\\\?\\"), "plain paths only: {kept}");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
||||
@@ -28,7 +28,7 @@ impl Desk {
|
||||
let files = cx
|
||||
.background_executor()
|
||||
.spawn(async move {
|
||||
let real = std::fs::canonicalize(&listed)?;
|
||||
let real = dunce::canonicalize(&listed)?;
|
||||
Ok::<_, std::io::Error>((markdown_under(&real)?, real))
|
||||
})
|
||||
.await;
|
||||
@@ -65,7 +65,7 @@ impl Desk {
|
||||
/// Puts `path` first in the recent list.
|
||||
pub fn remember(&mut self, path: &std::path::Path, cx: &mut Context<Self>) {
|
||||
// One spelling per file: its real path.
|
||||
let remembered = std::fs::canonicalize(path)
|
||||
let remembered = dunce::canonicalize(path)
|
||||
.and_then(|path| ely_files::recent::remember(&self.recent_file, &path));
|
||||
match remembered {
|
||||
Ok(list) => self.recent = list,
|
||||
@@ -82,7 +82,7 @@ impl Desk {
|
||||
|
||||
/// Tab `id` shows `path`; the recent list follows.
|
||||
pub fn track_recent(&mut self, id: u64, path: &std::path::Path, cx: &mut Context<Self>) {
|
||||
let Ok(real) = std::fs::canonicalize(path) else {
|
||||
let Ok(real) = dunce::canonicalize(path) else {
|
||||
return log::warn!("mark: {} is gone; the recent list keeps it", path.display());
|
||||
};
|
||||
if self.remembered.get(&id) == Some(&real) {
|
||||
@@ -129,7 +129,7 @@ impl Desk {
|
||||
return cx.notify();
|
||||
}
|
||||
// A file gone is reported by the open itself.
|
||||
if let Ok(real) = std::fs::canonicalize(&file) {
|
||||
if let Ok(real) = dunce::canonicalize(&file) {
|
||||
self.going = Some((real, at));
|
||||
}
|
||||
self.open_file(file, cx);
|
||||
@@ -137,11 +137,11 @@ impl Desk {
|
||||
|
||||
/// The tab showing `path`, by real path.
|
||||
pub fn tab_of(&self, path: &std::path::Path) -> Option<u64> {
|
||||
let real = std::fs::canonicalize(path).ok()?;
|
||||
let real = dunce::canonicalize(path).ok()?;
|
||||
let held = |tab: &&ely_office::Tab<crate::outside::Extra, crate::engine::Mark>| {
|
||||
tab.session
|
||||
.path()
|
||||
.and_then(|open| std::fs::canonicalize(open).ok())
|
||||
.and_then(|open| dunce::canonicalize(open).ok())
|
||||
== Some(real.clone())
|
||||
};
|
||||
self.core.tabs.iter().find(held).map(|tab| tab.id)
|
||||
|
||||
@@ -91,7 +91,7 @@ impl Keeping {
|
||||
Marker::Clean | Marker::Discarded => None,
|
||||
};
|
||||
if let Some(path) = &kept.path {
|
||||
match std::fs::canonicalize(path) {
|
||||
match dunce::canonicalize(path) {
|
||||
// The file reopens as it is on disk.
|
||||
Ok(real) => waiting.push(Waiting {
|
||||
kept: Kept {
|
||||
@@ -215,7 +215,7 @@ impl Desk {
|
||||
let real = tab
|
||||
.session
|
||||
.path()
|
||||
.and_then(|path| std::fs::canonicalize(path).ok());
|
||||
.and_then(|path| dunce::canonicalize(path).ok());
|
||||
let Some(Waiting {
|
||||
kept, text: back, ..
|
||||
}) = self.keeping.take(real.as_ref(), id)
|
||||
|
||||
@@ -111,7 +111,7 @@ impl Side {
|
||||
// Open files by real path, as the folder lists them.
|
||||
let reals: Vec<(u64, PathBuf)> = open
|
||||
.iter()
|
||||
.filter_map(|(id, path, _)| Some((*id, std::fs::canonicalize(path).ok()?)))
|
||||
.filter_map(|(id, path, _)| Some((*id, dunce::canonicalize(path).ok()?)))
|
||||
.collect();
|
||||
let sources: Vec<(Option<u64>, PathBuf)> = match (self.wide, &desk.folder) {
|
||||
(true, Some(folder)) => folder
|
||||
|
||||
Reference in new issue
Block a user