Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

fix(start): a picked project folder shows in Location, and Windows suggests one to begin with

Jareerba3eabb65c0c
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index 5377858e..10604c03 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -251,9 +251,19 @@ pub const SHELF_KINDS: [PackageKind; 4] = [
/// `name` under the home directory, as a path string; empty when there is
/// no home to speak of, and the form then asks for a folder outright.
+///
+/// The platform's own answer, not `$HOME`: Windows does not set that, so
+/// every folder the app suggested there came up empty. `name` is written
+/// with `/` and joined a part at a time, so the separators match.
pub(crate) fn home_folder(name: &str) -> String {
- std::env::var("HOME")
- .map(|home| format!("{home}/{name}"))
+ std::env::home_dir()
+ .filter(|home| !home.as_os_str().is_empty())
+ .map(|home| {
+ name.split('/')
+ .fold(home, |path, part| path.join(part))
+ .to_string_lossy()
+ .into_owned()
+ })
.unwrap_or_default()
}
@@ -8388,10 +8398,24 @@ impl Studio {
#[cfg(test)]
mod tests {
- use super::{Command, Footprint, Studio, key_commands, place_in, shown, write_keyable};
+ use super::{
+ Command, Footprint, Studio, home_folder, key_commands, place_in, shown, write_keyable,
+ };
const FRAME: (u32, u32) = (1920, 1080);
+ /// A suggested folder sits under the home directory, with the
+ /// platform's separators throughout, and is never empty on a machine
+ /// that has a home: the launch sheet's Location starts from it.
+ #[test]
+ fn home_folder_is_under_home_with_native_separators() {
+ let home = std::env::home_dir().expect("a home directory");
+ let folder = std::path::PathBuf::from(home_folder("Desktop/Concat"));
+ assert_eq!(folder, home.join("Desktop").join("Concat"));
+ #[cfg(windows)]
+ assert!(!folder.to_string_lossy().contains('/'));
+ }
+
/// A quarter turn swaps the bounds' pixel extents, which in fractions
/// of a 16:9 frame is not a swap of the numbers.
#[test]
diff --git a/src/crates/concat/ui/start.slint b/src/crates/concat/ui/start.slint
index 14f8773e..cdf723c9 100644
--- a/src/crates/concat/ui/start.slint
+++ b/src/crates/concat/ui/start.slint
@@ -8,6 +8,7 @@ import { FocusRing } from "primitives/focus-ring.slint";
import { Glyph, Icon } from "icons.slint";
import { ThinScrollbar } from "primitives/scrollbar.slint";
import { Tip } from "primitives/tooltip.slint";
+import { Focus } from "util.slint";
// The launch screen: a launcher with a rail, and the window's own ground
// under all of it — no card around the whole thing, no shadow. A setup
@@ -1184,7 +1185,15 @@ export component NewProjectDialog inherits Modal {
LinkButton {
label: I18n.t("Choose…");
enabled: !root.data.busy;
- clicked => { root.browse(); }
+ // The field beside this ignores a new value while it
+ // holds the caret (see PlainInput), so a folder picked
+ // with the caret still in it never showed. Let go of
+ // it first; the window's press-away blur only covers
+ // a mouse, not a touch, a pen or the keyboard.
+ clicked => {
+ Focus.release();
+ root.browse();
+ }
}
}
}