add index info on Open Current Folder result

This commit is contained in:
Jeremy Wu 2020-06-01 05:52:01 +10:00
parent 758b565f01
commit 5f13fd8a80
3 changed files with 12 additions and 9 deletions

View file

@ -20,12 +20,14 @@ namespace Flow.Launcher.Plugin.Explorer
if (record.Type == ResultType.File)
{
contextMenus.Add(CreateOpenWithEditorResult(record));
contextMenus.Add(CreateOpenContainingFolderResult(record));
}
contextMenus.Add(CreateOpenContainingFolderResult(record));
if (record.ShowIndexState)
contextMenus.Add(new Result { Title = "Indexed: " + (record.WindowsIndexed ? "Yes" : "No"),
Score = 501, IcoPath = Constants.IndexImagePath });
contextMenus.Add(new Result {Title = "Indexed: " + (record.WindowsIndexed ? "Yes" : "No"),
SubTitle = "Location: " + record.FullPath,
Score = 501, IcoPath = Constants.IndexImagePath});
var icoPath = (record.Type == ResultType.File) ? Constants.FileImagePath : Constants.FolderImagePath;
var fileOrFolder = (record.Type == ResultType.File) ? "file" : "folder";

View file

@ -45,7 +45,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
};
}
internal static Result CreateOpenCurrentFolderResult(string path, bool isPreviousDirectoryLevel)
internal static Result CreateOpenCurrentFolderResult(string path, bool isPreviousDirectoryLevel, bool windowsIndexed = false)
{
var folderName = path;
@ -81,7 +81,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search
{
FilesFolders.OpenPath(path);
return true;
}
},
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = folderName, ShowIndexState = true, WindowsIndexed = windowsIndexed }
};
}

View file

@ -48,7 +48,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
var results = new List<Result>();
var currentFolderResult = CreateOpenCurrentFolderResult(FilesFolders.LocationExists, querySearch);
var currentFolderResult = CreateOpenCurrentFolderResult(FilesFolders.LocationExists, querySearch, WindowsIndexExists(querySearch));
if (currentFolderResult == null)
return new List<Result>();
@ -113,17 +113,17 @@ namespace Flow.Launcher.Plugin.Explorer.Search
return _indexSearch.PathIsIndexed(path);
}
private Result CreateOpenCurrentFolderResult(Func<string, bool> locationExists, string querySearchString)
private Result CreateOpenCurrentFolderResult(Func<string, bool> locationExists, string querySearchString, bool indexExists)
{
if (locationExists(querySearchString))
return ResultManager.CreateOpenCurrentFolderResult(querySearchString, false);
return ResultManager.CreateOpenCurrentFolderResult(querySearchString, false, indexExists);
var previousDirectoryPath = FilesFolders.GetPreviousExistingDirectory(FilesFolders.LocationExists, querySearchString);
if (string.IsNullOrEmpty(previousDirectoryPath))
return null;
return ResultManager.CreateOpenCurrentFolderResult(previousDirectoryPath, true);
return ResultManager.CreateOpenCurrentFolderResult(previousDirectoryPath, true, indexExists);
}
}
}