diff --git a/Community.PowerToys.Run.Plugin.Everything.csproj b/Community.PowerToys.Run.Plugin.Everything.csproj
index 4a9053d..5c22233 100644
--- a/Community.PowerToys.Run.Plugin.Everything.csproj
+++ b/Community.PowerToys.Run.Plugin.Everything.csproj
@@ -122,6 +122,9 @@
True
\
+
+ PreserveNewest
+
diff --git a/Main.cs b/Main.cs
index 6a468ef..4cf23b5 100644
--- a/Main.cs
+++ b/Main.cs
@@ -28,7 +28,6 @@ namespace Community.PowerToys.Run.Plugin.Everything
private const string Top = nameof(Top);
private const string NoPreview = nameof(NoPreview);
private readonly string reservedStringPattern = @"^[\/\\\$\%]+$|^.*[<>].*$";
- /*private bool _wait;*/
private bool _top;
private bool _preview;
@@ -44,12 +43,6 @@ namespace Community.PowerToys.Run.Plugin.Everything
DisplayLabel = Resources.Top,
Value = false,
},
- /*new PluginAdditionalOption()
- {
- Key = Wait,
- DisplayLabel = Resources.Wait,
- Value = false,
- },*/
new PluginAdditionalOption()
{
Key = NoPreview,
@@ -71,8 +64,6 @@ namespace Community.PowerToys.Run.Plugin.Everything
}
}
- /*private static CancellationTokenSource source;*/
-
public void Init(PluginInitContext context)
{
_context = context;
@@ -90,7 +81,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to keep the process alive but will log the exception")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Already validated")]
- public List Query(Query query, bool isFullQuery)
+ public List Query(Query query, bool delayedExecution)
{
List results = new List();
if (!string.IsNullOrEmpty(query.Search))
@@ -101,13 +92,9 @@ namespace Community.PowerToys.Run.Plugin.Everything
if (!regexMatch.Success)
{
- /*source?.Cancel();
- source = new CancellationTokenSource();
- CancellationToken token = source.Token;
- source.CancelAfter(_wait ? 2500 : 150);*/
try
{
- results.AddRange(EverythingSearch(searchQuery, _top, _preview/*, token, _wait*/));
+ results.AddRange(EverythingSearch(searchQuery, _top, _preview));
}
catch (OperationCanceledException)
{
@@ -132,7 +119,6 @@ namespace Community.PowerToys.Run.Plugin.Everything
}
catch (Exception e)
{
- /*source.Cancel();*/
Log.Exception("Everything Exception", e, GetType());
}
}
@@ -170,18 +156,15 @@ namespace Community.PowerToys.Run.Plugin.Everything
public void UpdateSettings(PowerLauncherPluginSettings settings)
{
- /*var wait = false;*/
var top = false;
var nopreview = false;
if (settings != null && settings.AdditionalOptions != null)
{
- /*wait = settings.AdditionalOptions.FirstOrDefault(x => x.Key == Wait)?.Value ?? false;*/
top = settings.AdditionalOptions.FirstOrDefault(x => x.Key == Top)?.Value ?? false;
nopreview = settings.AdditionalOptions.FirstOrDefault(x => x.Key == NoPreview)?.Value ?? false;
}
_top = top;
- /*_wait = wait;*/
_preview = nopreview;
}
diff --git a/NativeMethods.cs b/NativeMethods.cs
index 856db87..ca3694d 100644
--- a/NativeMethods.cs
+++ b/NativeMethods.cs
@@ -92,19 +92,49 @@ namespace Community.PowerToys.Run.Plugin.Everything
[DllImport(dllName)]
public static extern void Everything_SetSort(Sort SortType);
- private const int max = 20;
+ private static uint max = 20;
+ private static Sort sort = Sort.DATE_MODIFIED_DESCENDING;
#pragma warning disable SA1503 // Braces should not be omitted
public static void EverythingSetup()
{
Everything_SetRequestFlags(Request.FULL_PATH_AND_FILE_NAME);
- Everything_SetSort(Sort.DATE_MODIFIED_DESCENDING);
+ GetCustomSettings();
+ Everything_SetSort(sort);
Everything_SetMax(max);
}
- public static IEnumerable EverythingSearch(string qry, bool top, bool preview/*, CancellationToken token, bool wait*/)
+ [SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1503:Braces should not be omitted", Justification = "stop wasting lines")]
+ [SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1501:Statement should not be on a single line", Justification = "stop wasting lines")]
+ private static void GetCustomSettings()
+ {
+ string[] strArr;
+ try { strArr = File.ReadAllLines("modules\\launcher\\Plugins\\Everything\\settings.toml"); }
+ catch { return; }
+ var culture = new System.Globalization.CultureInfo("en-US");
+ foreach (string str in strArr)
+ {
+ if (str.Length == 0 || str[0] == '#') continue;
+ string[] kv = str.Split('=');
+ if (kv.Length != 2) continue;
+ switch (kv[0].Trim())
+ {
+ case "max":
+ try { max = uint.Parse(kv[1].Trim(), culture.NumberFormat); }
+ catch { }
+ break;
+ case "sort":
+ try { sort = (Sort)int.Parse(kv[1].Trim(), culture.NumberFormat); }
+ catch { }
+ break;
+ default:
+ continue;
+ }
+ }
+ }
+
+ public static IEnumerable EverythingSearch(string qry, bool top, bool preview)
{
_ = Everything_SetSearchW(qry);
- /*if (token.IsCancellationRequested) token.ThrowIfCancellationRequested();*/
if (!Everything_QueryW(true))
{
throw new Win32Exception("Unable to Query");
@@ -114,7 +144,6 @@ namespace Community.PowerToys.Run.Plugin.Everything
for (uint i = 0; i < resultCount; i++)
{
- /*if (token.IsCancellationRequested) break;*/
StringBuilder sb = new StringBuilder(260);
Everything_GetResultFullPathName(i, sb, 260);
string fullPath = sb.ToString();
@@ -162,17 +191,6 @@ namespace Community.PowerToys.Run.Plugin.Everything
if (top) r.Score = (int)(max - i);
yield return r;
}
-
- /*if (token.IsCancellationRequested && !wait)
- {
- yield return new Result()
- {
- Title = Resources.timeout,
- SubTitle = Resources.enable_wait,
- IcoPath = Main.WarningIcon,
- Score = int.MaxValue,
- };
- }*/
}
internal static readonly Hashtable Icons = GetFileTypeAndIcon();
diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs
index 5f35077..d78fc97 100644
--- a/Properties/Resources.Designer.cs
+++ b/Properties/Resources.Designer.cs
@@ -178,7 +178,7 @@ namespace Community.PowerToys.Run.Plugin.Everything.Properties {
}
///
- /// Looks up a localized string similar to Top - Insert result at the top of the list, may cause pre-selectino issue..
+ /// Looks up a localized string similar to Top - Insert result at the top of the list, may cause pre-selection issue..
///
public static string Top {
get {
diff --git a/Properties/Resources.resx b/Properties/Resources.resx
index e9aa6fb..91ff578 100644
--- a/Properties/Resources.resx
+++ b/Properties/Resources.resx
@@ -162,4 +162,4 @@
Wait - Wait longer for the query to finish, enable only if prompted to.
-
+
\ No newline at end of file
diff --git a/plugin.json b/plugin.json
index 9b60533..78b25ba 100644
--- a/plugin.json
+++ b/plugin.json
@@ -4,7 +4,7 @@
"IsGlobal": true,
"Name": "Everything",
"Author": "Yu Chieh (Victor) Lin",
- "Version": "0.56.2.2",
+ "Version": "0.58.0",
"Language": "csharp",
"Website": "https://github.com/lin-ycv/EverythingPowerToys",
"ExecuteFileName": "Community.PowerToys.Run.Plugin.Everything.dll",
diff --git a/settings.toml b/settings.toml
new file mode 100644
index 0000000..3a00228
--- /dev/null
+++ b/settings.toml
@@ -0,0 +1,13 @@
+# This is the settings file to override the behaviour for "Everything for PowerToys"
+# to override a setting, uncomment that line by uncommenting and changing the value
+# ie: "# max = 20" -> "max = 10"
+
+# Set max amount of results to return [default: 20]
+# max = 20
+
+# Set result sorting method [default: 14]
+# https://www.voidtools.com/support/everything/sdk/everything_getsort/
+# sort = 14
+
+# There are no more override options
+# Restart of powertoys is needed if values are changed
\ No newline at end of file