Skip to content

Commit bd64512

Browse files
committed
add open containing folder to file results
1 parent 90b7559 commit bd64512

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace Flow.Launcher.Plugin.SharedCommands
88
public static class FilesFolders
99
{
1010
private const string FileExplorerProgramName = "explorer";
11+
12+
private const string FileExplorerProgramEXE = "explorer.exe";
13+
1114
public static void Copy(this string sourcePath, string targetPath)
1215
{
1316
// Get the subdirectories for the specified directory.
@@ -128,6 +131,11 @@ public static void OpenPath(string fileOrFolderPath)
128131
}
129132
}
130133

134+
public static void OpenContainingFolder(string path)
135+
{
136+
Process.Start(FileExplorerProgramEXE, $" /select,\"{path}\"");
137+
}
138+
131139
///<summary>
132140
/// This checks whether a given string is a directory path or network location string.
133141
/// It does not check if location actually exists.

Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private Result CreateOpenContainingFolderResult(SearchResult record)
156156
{
157157
try
158158
{
159-
Process.Start("explorer.exe", $" /select,\"{record.FullPath}\"");
159+
FilesFolders.OpenContainingFolder(record.FullPath);
160160
}
161161
catch (Exception e)
162162
{

Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ internal static class Constants
1818

1919
internal const string ToolTipOpenDirectory = "Ctrl + Enter to open the directory";
2020

21+
internal const string ToolTipOpenContainingFolder = "Ctrl + Enter to open the containing folder";
22+
2123
internal const char AllFilesFolderSearchWildcard = '>';
2224

2325
internal const char DirectorySeperator = '\\';

Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Flow.Launcher.Infrastructure;
22
using Flow.Launcher.Plugin.SharedCommands;
33
using System;
4+
using System.Diagnostics;
45
using System.IO;
56
using System.Linq;
67
using System.Windows;
@@ -105,7 +106,14 @@ internal Result CreateFileResult(string filePath, Query query, bool showIndexSta
105106
{
106107
try
107108
{
108-
FilesFolders.OpenPath(filePath);
109+
if (c.SpecialKeyState.CtrlPressed)
110+
{
111+
FilesFolders.OpenContainingFolder(filePath);
112+
}
113+
else
114+
{
115+
FilesFolders.OpenPath(filePath);
116+
}
109117
}
110118
catch (Exception ex)
111119
{
@@ -114,6 +122,8 @@ internal Result CreateFileResult(string filePath, Query query, bool showIndexSta
114122

115123
return true;
116124
},
125+
TitleToolTip = Constants.ToolTipOpenContainingFolder,
126+
SubTitleToolTip = Constants.ToolTipOpenContainingFolder,
117127
ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath, ShowIndexState = showIndexState, WindowsIndexed = windowsIndexed }
118128
};
119129
return result;

0 commit comments

Comments
 (0)