View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001771 | Double Commander | File operations | public | 2017-03-16 20:15 | 2020-11-30 07:43 |
Reporter | forbjok | Assigned To | Alexx2000 | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Projection | none | ETA | none | ||
Platform | x86-64 | OS | Windows | OS Version | Windows 10 |
Product Version | 0.7.8 | ||||
Target Version | 0.8.0 | Fixed in Version | 0.8.0 | ||
Summary | 0001771: Context menu commands run with wrong current directory | ||||
Description | When a context menu command (defined in HKEY_CLASSES_ROOT -> Folder -> shell -> (command name) -> command) is executed in Windows Explorer by right-clicking the background or a subdirectrory, it is executed with current working directory set to the directory you are currently browsing. In DC, it works as expected when right-clicking the background, but if right-clicking a subdirectory and running a command it is instead always run with current directory set to the DC executable's directory. | ||||
Steps To Reproduce | Right-click a file or subdirectory and execute an action in the Windows context menu. It will get run with current working directory set to the Double Commander executable's path. | ||||
Additional Information | I dug around in the code a bit and found out what's causing it. In TShellContextMenu.PopUp, it's only setting the TCMINVOKECOMMANDINFO's lpDirectory if FBackground is true - and FBackground is only true if the user clicks the background rather than a subdirectory. So if a subdirectory is right-clicked, any commands are executed with lpDirectory unset, resulting in the current directory defaulting to Double Commander's installation path. Code: if FBackground then begin lpDirectory := PAnsiChar(CeUtf8ToSys(FFiles[0].FullPath)); end; I don't know the reasoning behind doing this, but to me this behavior seems incorrect. It seems to me like the desirable behavior should be to do the same thing Windows Explorer does, and execute the command with its working directory set to the currently browsed directory regardless of whether the background or a subdirectory is clicked. This means that if a file or subdirectory is right-clicked, lpDirectory should be set to the item's parent directory rather than the item itself. I have attached a patch with a change that seems to fix the problem. | ||||
Tags | No tags attached. | ||||
Attached Files | ushellcontextmenu.pas.patch (533 bytes)
Index: ushellcontextmenu.pas =================================================================== --- ushellcontextmenu.pas (revision 7455) +++ ushellcontextmenu.pas (working copy) @@ -725,6 +725,10 @@ nShow := SW_NORMAL; if FBackground then begin lpDirectory := PAnsiChar(CeUtf8ToSys(FFiles[0].FullPath)); + end + else + begin + lpDirectory := PAnsiChar(CeUtf8ToSys(ExtractFilePath(FFiles[0].FullPath))); end; end; | ||||
Fixed in Revision | 7456 | ||||
Operating system | Windows | ||||
Widgetset | Win32 | ||||
Architecture | 64-bit | ||||
Date Modified | Username | Field | Change |
---|---|---|---|
2017-03-16 20:15 | forbjok | New Issue | |
2017-03-16 20:15 | forbjok | File Added: ushellcontextmenu.pas.patch | |
2017-03-17 23:05 | Alexx2000 | Fixed in Revision | => 7456 |
2017-03-17 23:05 | Alexx2000 | Assigned To | => Alexx2000 |
2017-03-17 23:05 | Alexx2000 | Status | new => resolved |
2017-03-17 23:05 | Alexx2000 | Resolution | open => fixed |
2017-03-17 23:05 | Alexx2000 | Fixed in Version | => 0.8.0 |
2017-03-17 23:05 | Alexx2000 | Target Version | => 0.8.0 |
2020-11-30 07:43 | Alexx2000 | Status | resolved => closed |