Skip to content

Commit

Permalink
Add file path to files search result in Folder Plugin (microsoft#139)
Browse files Browse the repository at this point in the history
* Add file path to files in Folder Plugin

* Add folder subtitle display path when wildcard '>' is used
  • Loading branch information
jjw24 authored Feb 15, 2020
1 parent 9b970ae commit d5f223f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Plugins/Wox.Plugin.Folder/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class Main : IPlugin, ISettingProvider, IPluginI18n, ISavable, IContextMe
public const string DeleteFileFolderImagePath = "Images\\deletefilefolder.png";
public const string CopyImagePath = "Images\\copy.png";

private string DefaultFolderSubtitleString = "Ctrl + Enter to open the directory";

private static List<string> _driverNames;
private PluginInitContext _context;

Expand Down Expand Up @@ -86,13 +88,13 @@ private static bool IsDriveOrSharedFolder(string search)
return false;
}

private Result CreateFolderResult(string title, string path, Query query)
private Result CreateFolderResult(string title, string subtitle, string path, Query query)
{
return new Result
{
Title = title,
IcoPath = path,
SubTitle = "Ctrl + Enter to open the directory",
SubTitle = subtitle,
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData,
Action = c =>
{
Expand Down Expand Up @@ -126,7 +128,7 @@ private List<Result> GetUserFolderResults(Query query)
var userFolderLinks = _settings.FolderLinks.Where(
x => x.Nickname.StartsWith(search, StringComparison.OrdinalIgnoreCase));
var results = userFolderLinks.Select(item =>
CreateFolderResult(item.Nickname, item.Path, query)).ToList();
CreateFolderResult(item.Nickname, DefaultFolderSubtitleString, item.Path, query)).ToList();
return results;
}

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

var folderSubtitleString = DefaultFolderSubtitleString;

try
{
// search folder and add results
Expand All @@ -211,7 +215,10 @@ private List<Result> QueryInternal_Directory_Exists(Query query)

if(fileSystemInfo is DirectoryInfo)
{
folderList.Add(CreateFolderResult(fileSystemInfo.Name, fileSystemInfo.FullName, query));
if (searchOption == SearchOption.AllDirectories)
folderSubtitleString = fileSystemInfo.FullName;

folderList.Add(CreateFolderResult(fileSystemInfo.Name, folderSubtitleString, fileSystemInfo.FullName, query));
}
else
{
Expand Down Expand Up @@ -240,6 +247,7 @@ private static Result CreateFileResult(string filePath, Query query)
var result = new Result
{
Title = Path.GetFileName(filePath),
SubTitle = filePath,
IcoPath = filePath,
TitleHighlightData = StringMatcher.FuzzySearch(query.Search, Path.GetFileName(filePath)).MatchData,
Action = c =>
Expand Down

0 comments on commit d5f223f

Please sign in to comment.