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:
Divyansh Srivastava
2020-08-10 15:51:02 -07:00
committed by GitHub
parent 082a78bd92
commit 3781d1e06b
3 changed files with 29 additions and 53 deletions

View File

@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -56,40 +57,8 @@ namespace Microsoft.Plugin.Shell
try
{
string basedir = null;
string dir = null;
string excmd = Environment.ExpandEnvironmentVariables(cmd);
if (Directory.Exists(excmd) && (cmd.EndsWith("/") || cmd.EndsWith(@"\")))
{
basedir = excmd;
dir = cmd;
}
else if (Directory.Exists(Path.GetDirectoryName(excmd) ?? string.Empty))
{
basedir = Path.GetDirectoryName(excmd);
var dirn = Path.GetDirectoryName(cmd);
dir = (dirn.EndsWith("/") || dirn.EndsWith(@"\")) ? dirn : cmd.Substring(0, dirn.Length + 1);
}
if (basedir != null)
{
var autocomplete = Directory.GetFileSystemEntries(basedir).
Select(o => dir + Path.GetFileName(o)).
Where(o => o.StartsWith(cmd, StringComparison.OrdinalIgnoreCase) &&
!results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase)) &&
!results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase))).ToList();
autocomplete.Sort();
results.AddRange(autocomplete.ConvertAll(m => new Result
{
Title = m,
IcoPath = IconPath,
Action = c =>
{
Execute(Process.Start, PrepareProcessStartInfo(m));
return true;
},
}));
}
List<Result> folderPluginResults = Folder.Main.GetFolderPluginResults(query);
results.AddRange(folderPluginResults);
}
catch (Exception e)
{