A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.
Rust archive-managerdesktop-appdual-paneexplorer-alternativefile-browserfile-explorerfile-managerfluent-designgpu-acceleratedgpuimacosmicaproductivityquick-lookrustrust-guitabswindowswindows-11windows-explorer
Alt or Ctrl+Shift at a drop makes shortcuts, as the cursor says (862)
denfry3b951a8d6406
diff --git a/crates/rf-app/src/ops.rs b/crates/rf-app/src/ops.rsindex a574ef4c..99783268 100644--- a/crates/rf-app/src/ops.rs+++ b/crates/rf-app/src/ops.rs@@ -554,30 +554,7 @@ impl FolderView {});cx.spawn(async move |this, cx| {let Ok(Some((paths, _))) = rx.await else { return };- let work = cx.background_spawn(async move {- let mut made = Vec::new();- for p in paths {- let stem = p.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_else(|| "Kısayol".into());- // never overwrite: "x.lnk", "x (2).lnk", …- let mut link = dir.join(format!("{stem}.lnk"));- let mut n = 2;- while link.exists() {- link = dir.join(format!("{stem} ({n}).lnk"));- n += 1;- }- match rf_win::shortcut::create(&link, &p) {- Ok(()) => made.push(link),- Err(e) => log::warn!("shortcut {link:?}: {e:#}"),- }- }- // Ctrl+Z takes these shortcuts away. Without a record it undid the operation BEFORE them: after a copy of two- // pictures and a mistaken "Paste shortcut", Ctrl+Z sent the two pictures to the Recycle Bin and left the shortcut- // (a Discord report, 1.0.0).- if !made.is_empty() {- crate::undo::push(crate::undo::UndoOp::CreatedAll { paths: made });- }- });- work.await;+ cx.background_spawn(async move { make_shortcuts(&paths, &dir) }).await;let _ = this.update(cx, |v, cx| v.refresh(cx));}).detach();@@ -1572,6 +1549,19 @@ impl FolderView {mod tests {// not `super::*`: gpui's `test` macro would shadow the built-in oneuse super::{Flattened, fileops, flatten, reflatten, unflatten};++ /// Issue 862: the keys whose cursor says "link" make shortcuts; Ctrl alone still copies and Shift alone moves.+ #[test]+ fn alt_or_ctrl_shift_at_the_drop_makes_shortcuts_when_the_source_allows_links() {+ use gpui_windows::dnd_hint::{COPY, LINK, MOVE};+ let all = COPY | MOVE | LINK;+ assert!(super::drop_makes_links(false, false, true, all), "Alt");+ assert!(super::drop_makes_links(true, true, false, all), "Ctrl+Shift");+ assert!(!super::drop_makes_links(true, false, false, all), "Ctrl: a copy");+ assert!(!super::drop_makes_links(false, true, false, all), "Shift: a move");+ assert!(!super::drop_makes_links(false, false, false, all));+ assert!(!super::drop_makes_links(false, false, true, COPY), "a copy-only source (an archive) is copied");+ }use super::{MENU_7Z, MENU_BULK_RENAME, MENU_COPY_PATH, MENU_EXTRACT_HERE, MENU_EXTRACT_PICK, MENU_EXTRACT_SMART, MENU_EXTRACT_TO,MENU_NEW_FOLDER, MENU_NEW_TAB, MENU_NEW_TEXT, MENU_OPEN_LOCATION, MENU_OTHER_COPY, MENU_OTHER_MOVE, MENU_OTHER_OPEN, MENU_PASTE,@@ -1718,6 +1708,37 @@ mod tests {}}+/// Makes a shortcut (.lnk) in `dir` to each of `paths`, never over an existing file ("x.lnk", "x (2).lnk", …), and records them for+/// Ctrl+Z. Blocks (the shell, the disk): worker thread only.+pub(crate) fn make_shortcuts(paths: &[std::path::PathBuf], dir: &std::path::Path) {+ let mut made = Vec::new();+ for p in paths {+ let stem = p.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_else(|| "Kısayol".into());+ let mut link = dir.join(format!("{stem}.lnk"));+ let mut n = 2;+ while link.exists() {+ link = dir.join(format!("{stem} ({n}).lnk"));+ n += 1;+ }+ match rf_win::shortcut::create(&link, p) {+ Ok(()) => made.push(link),+ Err(e) => log::warn!("shortcut {link:?}: {e:#}"),+ }+ }+ // Ctrl+Z takes these shortcuts away. Without a record it undid the operation BEFORE them: after a copy of two+ // pictures and a mistaken "Paste shortcut", Ctrl+Z sent the two pictures to the Recycle Bin and left the shortcut+ // (a Discord report, 1.0.0).+ if !made.is_empty() {+ crate::undo::push(crate::undo::UndoOp::CreatedAll { paths: made });+ }+}++/// Whether a drop makes shortcuts instead of moving or copying (issue 862): Alt, or Ctrl+Shift, held at the drop, as in Explorer and as+/// the drag's cursor already says (`gpui_windows::dnd_hint`), when the drag's source allows links (`allowed`, `dnd_hint` bits).+pub(crate) fn drop_makes_links(ctrl: bool, shift: bool, alt: bool, allowed: u32) -> bool {+ (alt || (ctrl && shift)) && allowed & gpui_windows::dnd_hint::LINK != 0+}+/// Copy or move for files dropped from another program (or another of our processes): [`rf_win::dnd::default_transfer`], but a/// copy when the drag's source does not allow moving (an archive's files extracted for the drag, a phone, a mail's attachment)./// Moving them anyway took the source's own files away, and Windows refused the drop outright before the GPUI fork chose an effectdiff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rsindex 39566e10..dc9f1924 100644--- a/crates/rf-app/src/workspace.rs+++ b/crates/rf-app/src/workspace.rs@@ -5936,10 +5936,19 @@ pub(crate) fn drop_files_then(paths: &ExternalPaths, dest: PathBuf, cx: &mut Appif sources.is_empty() {return;}- let (ctrl, shift) = unsafe {- use windows::Win32::UI::Input::KeyboardAndMouse::{GetAsyncKeyState, VK_CONTROL, VK_SHIFT};- (GetAsyncKeyState(VK_CONTROL.0 as i32) < 0, GetAsyncKeyState(VK_SHIFT.0 as i32) < 0)+ let (ctrl, shift, alt) = unsafe {+ use windows::Win32::UI::Input::KeyboardAndMouse::{GetAsyncKeyState, VK_CONTROL, VK_MENU, VK_SHIFT};+ (GetAsyncKeyState(VK_CONTROL.0 as i32) < 0, GetAsyncKeyState(VK_SHIFT.0 as i32) < 0, GetAsyncKeyState(VK_MENU.0 as i32) < 0)};+ // Alt or Ctrl+Shift: shortcuts to the items, made in the folder (a phone's or an FTP folder takes no shortcut: the items go as usual)+ if crate::ops::drop_makes_links(ctrl, shift, alt, gpui_windows::dnd_hint::allowed()) && !rf_win::ftp::is_ftp(&dest) && dest.is_dir() {+ cx.spawn(async move |cx| {+ cx.background_spawn(async move { crate::ops::make_shortcuts(&sources, &dest) }).await;+ cx.update(after);+ })+ .detach();+ return;+ }// (a copy into the items' own folder is a duplicate of them, issue 219; a move there is nothing)if rf_win::dnd::is_invalid_drop_as(&sources, &dest, crate::ops::drop_transfer(&sources, &dest, ctrl, shift)) {return;