From d537946ff60eb140cb76a6371fd3a37dab4c2fb2 Mon Sep 17 00:00:00 2001 From: Fabio Lussi Date: Sat, 10 Oct 2026 21:51:08 +0200 Subject: [PATCH] Make the save-dialog memory test path-separator independent (#2745) (#2782) pick_save builds the suggested path with Path::join, which uses `\` on Windows, but save_dialogs_remember_where_each_document_was_last_saved compared it against hard-coded "/dir/name" strings, so it failed on windows-latest. The behaviour is correct; build the expected values with Path::join too. Co-authored-by: Fabio Lussi <198260595+itrycodinganditsbad@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- crates/ui-egui/src/file_dialog/tests.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/file_dialog/tests.rs b/crates/ui-egui/src/file_dialog/tests.rs index 14e90f76a8..56eb45b6ff 100644 --- a/crates/ui-egui/src/file_dialog/tests.rs +++ b/crates/ui-egui/src/file_dialog/tests.rs @@ -305,16 +305,18 @@ fn save_dialogs_remember_where_each_document_was_last_saved() { FileDialogRequest::Save { suggested } => suggested.clone(), other => panic!("save dialog expected, got {other:?}"), }; + // Suggestions are built with `Path::join`, which uses `\` on Windows (#2745). + let joined = |dir: &str, name: &str| std::path::Path::new(dir).join(name).to_string_lossy().into_owned(); // An export starts beside the document; the user saves it under /renders instead. app.pick_save("result.png", |_, _| Ok(Value::Null)).unwrap(); app.poll_file_dialog(&ctx, None); - assert_eq!(suggested(&open), "/proj/result.png"); + assert_eq!(suggested(&open), joined("/proj", "result.png")); answer(&open, Some(FileDialogAnswer::SaveTo("/renders/result.png".into()))); app.poll_file_dialog(&ctx, None); // The next export starts in /renders; Save As still offers the document's own path. app.pick_save("again.png", |_, _| Ok(Value::Null)).unwrap(); app.poll_file_dialog(&ctx, None); - assert_eq!(suggested(&open), "/renders/again.png"); + assert_eq!(suggested(&open), joined("/renders", "again.png")); answer(&open, None); app.poll_file_dialog(&ctx, None); menus::invoke(&mut app, &ctx, "file.saveAs", json!({})).unwrap(); @@ -330,7 +332,7 @@ fn save_dialogs_remember_where_each_document_was_last_saved() { app.poll_file_dialog(&ctx, None); app.pick_save("third.png", |_, _| Ok(Value::Null)).unwrap(); app.poll_file_dialog(&ctx, None); - assert_eq!(suggested(&open), "/renders/third.png"); + assert_eq!(suggested(&open), joined("/renders", "third.png")); answer(&open, None); app.poll_file_dialog(&ctx, None); // Another document has its own memory: untitled, it starts wherever the shell defaults. @@ -348,7 +350,7 @@ fn save_dialogs_remember_where_each_document_was_last_saved() { app.session.set_active(0); app.pick_save("swap.png", |_, _| Ok(Value::Null)).unwrap(); app.poll_file_dialog(&ctx, None); - assert_eq!(suggested(&open), "/renders/swap.png"); + assert_eq!(suggested(&open), joined("/renders", "swap.png")); app.session.set_active(1); answer(&open, Some(FileDialogAnswer::SaveTo("/moved/swap.png".into()))); app.poll_file_dialog(&ctx, None); @@ -358,7 +360,7 @@ fn save_dialogs_remember_where_each_document_was_last_saved() { app.run("file.close", json!({"document": 1})).unwrap(); app.pick_save("last.png", |_, _| Ok(Value::Null)).unwrap(); app.poll_file_dialog(&ctx, None); - assert_eq!(suggested(&open), "/moved/last.png"); + assert_eq!(suggested(&open), joined("/moved", "last.png")); assert!(!app.save_dirs.contains_key(&second)); answer(&open, None); app.poll_file_dialog(&ctx, None);