Fix Ctrl+Enter on file results opening the file instead of its folder with custom file managers
Fixes #2870
In ResultManager.CreateFileResult, Ctrl+Enter called OpenFolder(filePath, filePath), so OpenDirectory received the file path as directoryPath. With a custom file manager, %d in the file argument was therefore replaced by the file path, and file managers such as QtTabBar or Tablacus Explorer opened the file instead of its containing folder.
This now passes Path.GetDirectoryName(filePath), the same way the folder result's Ctrl+Enter already calls OpenDirectory(Path.GetDirectoryName(path), path).
Impact:
- Windows Explorer: unchanged (only the file path is used when a file is given).
- Built-in Total Commander, Directory Opus and Files profiles: unchanged (their file argument only uses
%f). - Profiles using
%din the file argument now get the containing folder, as intended. - Side effect: with Everything run count enabled, Ctrl+Enter on a file now increments the run count of the folder instead of the file, consistent with what is opened.
Tested on Flow Launcher 2.1.4 (portable copy) with Tablacus Explorer and file argument "%d": Ctrl+Enter on a .txt file now opens its folder.
Summary by cubic
Summary of changes
Fixes Ctrl+Enter on file results in the Explorer plugin so it opens the file's containing folder instead of the file itself when a custom file manager is used.
- Changed:
OpenFolder(filePath, filePath)now passesPath.GetDirectoryName(filePath)as the directory path, matching how folder results already handle Ctrl+Enter. - Impact: Windows Explorer and built-in Total Commander, Directory Opus, and Files profiles are unaffected, as they only use the file path or
%fin their arguments. - Side effect: With Everything run count enabled, Ctrl+Enter on a file now increments the folder's run count instead of the file's, consistent with what is actually opened.
- Memory and security: No memory usage impacts or security risks.
- Tests: No unit tests were added.
Release Note
Ctrl+Enter on a file result now opens its containing folder as expected when using custom file managers.