Bounce Mix: a session path without a folder starts in the default one
A relative session path has an empty parent, which made the default "/<name> Bounce.wav". Ignore an empty parent so it falls back to the default folder, as for a session never saved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
eb5bf699c7
commit
285d9fecd5
|
|
@ -85,7 +85,12 @@ impl Dialogs {
|
|||
}
|
||||
"session.new" => Dialog::NewSession { name: "Untitled".into(), sample_rate: 48_000, demo: false },
|
||||
"file.bounce_mix" => {
|
||||
let dir = e.path.as_deref().and_then(|p| std::path::Path::new(p).parent()).map_or(home.clone(), |d| d.display().to_string());
|
||||
let dir = e
|
||||
.path
|
||||
.as_deref()
|
||||
.and_then(|p| std::path::Path::new(p).parent())
|
||||
.filter(|d| !d.as_os_str().is_empty())
|
||||
.map_or(home.clone(), |d| d.display().to_string());
|
||||
Dialog::Bounce { path: format!("{dir}/{name} Bounce.wav"), format: "wav".into(), bit_depth: "24".into(), normalize: false }
|
||||
}
|
||||
"file.import_audio" => Dialog::PathPrompt { cmd: id.into(), title: "Import Audio".into(), path: home, key: "path".into() },
|
||||
|
|
|
|||
|
|
@ -34,3 +34,21 @@ fn bounce_starts_in_the_session_folder_and_browse_picks_the_file_and_format() {
|
|||
other => panic!("{other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bounce_of_a_session_with_a_relative_path_starts_in_the_default_folder() {
|
||||
let mut engine = soundcraft_engine::demo::demo_engine();
|
||||
engine.path = Some("Midnight Groove.scraft".into());
|
||||
let name = engine.session().name.clone();
|
||||
let mut app = SoundApp::new(engine, None, Services::default());
|
||||
assert!(app.dialogs.open_for_command(&app.engine, "file.bounce_mix"));
|
||||
let mut fresh = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default());
|
||||
assert!(fresh.dialogs.open_for_command(&fresh.engine, "file.bounce_mix"));
|
||||
match (&app.dialogs.open, &fresh.dialogs.open) {
|
||||
(Some(Dialog::Bounce { path, .. }), Some(Dialog::Bounce { path: unsaved, .. })) => {
|
||||
assert_ne!(path.as_str(), format!("/{name} Bounce.wav"));
|
||||
assert_eq!(path, unsaved, "the same folder as a session never saved");
|
||||
}
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue