Skip to content

Commit d5f223f

Browse files
authored
Add file path to files search result in Folder Plugin (#139)
* Add file path to files in Folder Plugin * Add folder subtitle display path when wildcard '>' is used
1 parent 9b970ae commit d5f223f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Plugins/Wox.Plugin.Folder/Main.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public class Main : IPlugin, ISettingProvider, IPluginI18n, ISavable, IContextMe
1717
public const string DeleteFileFolderImagePath = "Images\\deletefilefolder.png";
1818
public const string CopyImagePath = "Images\\copy.png";
1919

20+
private string DefaultFolderSubtitleString = "Ctrl + Enter to open the directory";
21+
2022
private static List<string> _driverNames;
2123
private PluginInitContext _context;
2224

@@ -86,13 +88,13 @@ private static bool IsDriveOrSharedFolder(string search)
8688
return false;
8789
}
8890

89-
private Result CreateFolderResult(string title, string path, Query query)
91+
private Result CreateFolderResult(string title, string subtitle, string path, Query query)
9092
{
9193
return new Result
9294
{
9395
Title = title,
9496
IcoPath = path,
95-
SubTitle = "Ctrl + Enter to open the directory",
97+
SubTitle = subtitle,
9698
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
9799
Action = c =>
98100
{
@@ -126,7 +128,7 @@ private List<Result> GetUserFolderResults(Query query)
126128
var userFolderLinks = _settings.FolderLinks.Where(
127129
x => x.Nickname.StartsWith(search, StringComparison.OrdinalIgnoreCase));
128130
var results = userFolderLinks.Select(item =>
129-
CreateFolderResult(item.Nickname, item.Path, query)).ToList();
131+
CreateFolderResult(item.Nickname, DefaultFolderSubtitleString, item.Path, query)).ToList();
130132
return results;
131133
}
132134

@@ -199,6 +201,8 @@ private List<Result> QueryInternal_Directory_Exists(Query query)
199201
var folderList = new List<Result>();
200202
var fileList = new List<Result>();
201203

204+
var folderSubtitleString = DefaultFolderSubtitleString;
205+
202206
try
203207
{
204208
// search folder and add results
@@ -211,7 +215,10 @@ private List<Result> QueryInternal_Directory_Exists(Query query)
211215

212216
if(fileSystemInfo is DirectoryInfo)
213217
{
214-
folderList.Add(CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, query));
218+
if (searchOption == SearchOption.AllDirectories)
219+
folderSubtitleString = fileSystemInfo.FullName;
220+
221+
folderList.Add(CreateFolderResult(fileSystemInfo.Name, folderSubtitleString, fileSystemInfo.FullName, query));
215222
}
216223
else
217224
{
@@ -240,6 +247,7 @@ private static Result CreateFileResult(string filePath, Query query)
240247
var result = new Result
241248
{
242249
Title = Path.GetFileName(filePath),
250+
SubTitle = filePath,
243251
IcoPath = filePath,
244252
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, Path.GetFileName(filePath)).MatchData,
245253
Action = c =>

0 commit comments

Comments
 (0)