Skip to content

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.

Context menu of the signed-in user's profile folder (801)

gelenmedya005a09689ac6
diff --git a/crates/rf-win/src/ctxmenu.rs b/crates/rf-win/src/ctxmenu.rs
index 95eacd4c..3847f4ac 100644
--- a/crates/rf-win/src/ctxmenu.rs
+++ b/crates/rf-win/src/ctxmenu.rs
@@ -70,7 +70,17 @@ fn folder(path: &Path) -> anyhow::Result<IShellFolder> {
fn menu_for_items(owner: HWND, items: &[PathBuf]) -> anyhow::Result<IContextMenu> {
let Some(parent) = items.first().and_then(|p| p.parent()) else { return ui_object_for_items(owner, items) };
if items.iter().all(|p| p.parent() == Some(parent)) {
- return ui_object_for_items(owner, items);
+ match ui_object_for_items(owner, items) {
+ Ok(cm) => return Ok(cm),
+ // The signed-in user's profile folder (C:\Users\<name>) is parsed into Windows' own "user files" namespace, not as a
+ // child of C:\Users, and that folder refuses the foreign ID (E_INVALIDARG: no menu at all, issue 801). The item through
+ // its real parent, or several through the desktop, as below.
+ Err(e) if items.len() == 1 => {
+ log::debug!("context menu through the folder: {e}; through the item's own parent");
+ return menu_for_one(owner, &items[0]);
+ }
+ Err(e) => log::debug!("context menu through the folder: {e}; through the desktop"),
+ }
}
// Items of several folders: the desktop's own menu for full ID lists knows no file type, so it had only the rows every file
// gets (issue 743, 1.0.7: two PDFs from two folders lost WPS's "PDF merge"; two pictures lost Rotate and the editors). The