mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
Consolidate folder and shell plugin (#5843)
* Added folder plugin functionality to shell plugin * Added QueryTextDisplay for shell plugin * Remove QueryTextDisplay change * Fix merge conflict issues
This commit is contained in:
committed by
GitHub
parent
082a78bd92
commit
3781d1e06b
@@ -27,20 +27,14 @@ namespace Microsoft.Plugin.Folder
|
||||
|
||||
private const string _fileExplorerProgramName = "explorer";
|
||||
|
||||
private readonly FolderSettings _settings;
|
||||
private readonly PluginJsonStorage<FolderSettings> _storage;
|
||||
private static readonly PluginJsonStorage<FolderSettings> _storage = new PluginJsonStorage<FolderSettings>();
|
||||
private static readonly FolderSettings _settings = _storage.Load();
|
||||
|
||||
private static List<string> _driverNames;
|
||||
private PluginInitContext _context;
|
||||
|
||||
private IContextMenu _contextMenuLoader;
|
||||
|
||||
public Main()
|
||||
{
|
||||
_storage = new PluginJsonStorage<FolderSettings>();
|
||||
_settings = _storage.Load();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_storage.Save();
|
||||
@@ -66,15 +60,7 @@ namespace Microsoft.Plugin.Folder
|
||||
throw new ArgumentNullException(paramName: nameof(query));
|
||||
}
|
||||
|
||||
var results = GetUserFolderResults(query);
|
||||
|
||||
string search = query.Search.ToLower(CultureInfo.InvariantCulture);
|
||||
if (!IsDriveOrSharedFolder(search))
|
||||
{
|
||||
return results;
|
||||
}
|
||||
|
||||
results.AddRange(QueryInternal_Directory_Exists(query));
|
||||
var results = GetFolderPluginResults(query);
|
||||
|
||||
// todo why was this hack here?
|
||||
foreach (var result in results)
|
||||
@@ -85,8 +71,28 @@ namespace Microsoft.Plugin.Folder
|
||||
return results;
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "Do not want to change the behavior of the application, but want to enforce static analysis")]
|
||||
public static List<Result> GetFolderPluginResults(Query query)
|
||||
{
|
||||
var results = GetUserFolderResults(query);
|
||||
string search = query.Search.ToLower(CultureInfo.InvariantCulture);
|
||||
|
||||
if (!IsDriveOrSharedFolder(search))
|
||||
{
|
||||
return results;
|
||||
}
|
||||
|
||||
results.AddRange(QueryInternalDirectoryExists(query));
|
||||
return results;
|
||||
}
|
||||
|
||||
private static bool IsDriveOrSharedFolder(string search)
|
||||
{
|
||||
if (search == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(search));
|
||||
}
|
||||
|
||||
if (search.StartsWith(@"\\", StringComparison.InvariantCulture))
|
||||
{ // share folder
|
||||
return true;
|
||||
@@ -124,7 +130,7 @@ namespace Microsoft.Plugin.Folder
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "Do not want to change the behavior of the application, but want to enforce static analysis")]
|
||||
private List<Result> GetUserFolderResults(Query query)
|
||||
private static List<Result> GetUserFolderResults(Query query)
|
||||
{
|
||||
if (query == null)
|
||||
{
|
||||
@@ -159,7 +165,7 @@ namespace Microsoft.Plugin.Folder
|
||||
};
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "Do not want to change the behavior of the application, but want to enforce static analysis")]
|
||||
private static List<Result> QueryInternal_Directory_Exists(Query query)
|
||||
private static List<Result> QueryInternalDirectoryExists(Query query)
|
||||
{
|
||||
var search = query.Search;
|
||||
var results = new List<Result>();
|
||||
|
||||
Reference in New Issue
Block a user