mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-05 11:49:40 +00:00
Fixed Windows Explorer opening the Documents folder instead of the file (#1015)
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
This commit is contained in:
1 parent
cb99e9a668
commit
553e02feb3
2 files changed
+29
-1
No files matched your search
@@ -18,6 +18,9 @@ use ashpd::desktop::open_uri::{OpenDirectoryRequest, OpenFileRequest};
|
||||
#[cfg(windows)]
|
||||
use std::os::windows::process::CommandExt;
|
||||
|
||||
#[cfg(any(windows, test))]
|
||||
use std::ffi::OsString;
|
||||
|
||||
/// Microsoft documents CREATE_NO_WINDOW as a process creation flag with value 0x08000000.
|
||||
#[cfg(windows)]
|
||||
const CREATE_NO_WINDOW: u32 = 0x08000000;
|
||||
@@ -972,7 +975,12 @@ async fn open_path_in_linux_file_manager(target: &FileManagerTarget) -> Result<(
|
||||
fn create_file_manager_command(target: &FileManagerTarget) -> Command {
|
||||
let mut command = Command::new("explorer.exe");
|
||||
if target.reveal_file {
|
||||
command.arg(format!("/select,{}", target.path.to_string_lossy()));
|
||||
//
|
||||
// Explorer reads its command line on its own. Passed as a regular argument, a path with
|
||||
// a space would be quoted as a whole, "/select,C:\My Folder\file.txt", which Explorer
|
||||
// does not understand: it opens the Documents folder instead.
|
||||
//
|
||||
command.raw_arg(explorer_select_argument(&target.path));
|
||||
} else {
|
||||
command.arg(&target.path);
|
||||
}
|
||||
@@ -980,6 +988,18 @@ fn create_file_manager_command(target: &FileManagerTarget) -> Command {
|
||||
command
|
||||
}
|
||||
|
||||
/// Builds the argument which makes Explorer show the given file selected in its folder.
|
||||
///
|
||||
/// Only the path is quoted, as in /select,"C:\My Folder\file.txt". Windows allows no quotation
|
||||
/// mark inside a file or folder name, so the path itself never needs escaping.
|
||||
#[cfg(any(windows, test))]
|
||||
fn explorer_select_argument(path: &Path) -> OsString {
|
||||
let mut argument = OsString::from("/select,\"");
|
||||
argument.push(path.as_os_str());
|
||||
argument.push("\"");
|
||||
argument
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn create_file_manager_command(target: &FileManagerTarget) -> Command {
|
||||
let mut command = Command::new("open");
|
||||
@@ -1043,6 +1063,13 @@ mod tests {
|
||||
assert_eq!(xdg_open_fallback_path(&target), temp_dir.path());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explorer_select_argument_quotes_only_the_path() {
|
||||
let argument = explorer_select_argument(Path::new(r"C:\Users\thorsten\AI Studio Events.log"));
|
||||
|
||||
assert_eq!(argument, OsString::from(r#"/select,"C:\Users\thorsten\AI Studio Events.log""#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn existing_directory_is_opened_directly() {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
|
||||
Reference in new issue
Block a user