diff --git a/installer/PowerToysSetup/Product.wxs b/installer/PowerToysSetup/Product.wxs
index 8dcbca9bc9..148b0ee6ef 100644
--- a/installer/PowerToysSetup/Product.wxs
+++ b/installer/PowerToysSetup/Product.wxs
@@ -901,7 +901,7 @@
-
+
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/FolderSettings.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/FolderSettings.cs
index bdcf7051a4..f4c813e05d 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/FolderSettings.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/FolderSettings.cs
@@ -11,5 +11,11 @@ namespace Microsoft.Plugin.Folder
{
[JsonProperty]
public List FolderLinks { get; } = new List();
+
+ [JsonProperty]
+ public int MaxFolderResults { get; set; } = 50;
+
+ [JsonProperty]
+ public int MaxFileResults { get; set; } = 50;
}
}
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Images/Warning.dark.png b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Images/Warning.dark.png
new file mode 100644
index 0000000000..9ae30c0548
Binary files /dev/null and b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Images/Warning.dark.png differ
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Images/Warning.light.png b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Images/Warning.light.png
new file mode 100644
index 0000000000..30e0d9737e
Binary files /dev/null and b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Images/Warning.light.png differ
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/de.xaml b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/de.xaml
index 58e266c7af..168650a55b 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/de.xaml
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/de.xaml
@@ -14,4 +14,7 @@
Copy path (Ctrl+C)
Open path in console (Ctrl+Shift+C)
Open containing folder (Ctrl+Shift+E)
+
+ Warning: Folder Plugin Results truncated.
+ Showing {0} of {1} results
\ No newline at end of file
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/en.xaml b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/en.xaml
index 810d1e6031..edef84f9f4 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/en.xaml
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/en.xaml
@@ -14,4 +14,7 @@
Copy path (Ctrl+C)
Open path in console (Ctrl+Shift+C)
Open containing folder (Ctrl+Shift+E)
+
+ Warning: Folder Plugin Results truncated.
+ Showing {0} of {1} results
\ No newline at end of file
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/pl.xaml b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/pl.xaml
index effc57a9ed..6df27b6824 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/pl.xaml
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/pl.xaml
@@ -14,4 +14,7 @@
Copy path (Ctrl+C)
Open path in console (Ctrl+Shift+C)
Open containing folder (Ctrl+Shift+E)
+
+ Warning: Folder Plugin Results truncated.
+ Showing {0} of {1} results
\ No newline at end of file
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/tr.xaml b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/tr.xaml
index 3761a990ad..a8f3271aa2 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/tr.xaml
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/tr.xaml
@@ -14,4 +14,7 @@
Copy path (Ctrl+C)
Open path in console (Ctrl+Shift+C)
Open containing folder (Ctrl+Shift+E)
+
+ Warning: Folder Plugin Results truncated.
+ Showing {0} of {1} results
\ No newline at end of file
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/zh-cn.xaml b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/zh-cn.xaml
index 0f5961ef7d..4f17a3023f 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/zh-cn.xaml
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/zh-cn.xaml
@@ -14,4 +14,7 @@
Copy path (Ctrl+C)
Open path in console (Ctrl+Shift+C)
Open containing folder (Ctrl+Shift+E)
+
+ Warning: Folder Plugin Results truncated.
+ Showing {0} of {1} results
\ No newline at end of file
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/zh-tw.xaml b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/zh-tw.xaml
index c085fba0e3..290e502049 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/zh-tw.xaml
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Languages/zh-tw.xaml
@@ -14,4 +14,7 @@
Copy path (Ctrl+C)
Open path in console (Ctrl+Shift+C)
Open containing folder (Ctrl+Shift+E)
+
+ Warning: Folder Plugin Results truncated.
+ Showing {0} of {1} results
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Main.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Main.cs
index 03eaafdddc..cd4d873c12 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Main.cs
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Main.cs
@@ -18,7 +18,7 @@ using Wox.Plugin;
namespace Microsoft.Plugin.Folder
{
- public class Main : IPlugin, ISettingProvider, IPluginI18n, ISavable, IContextMenu
+ public class Main : IPlugin, ISettingProvider, IPluginI18n, ISavable, IContextMenu, IDisposable
{
public const string FolderImagePath = "Images\\folder.dark.png";
public const string FileImagePath = "Images\\file.dark.png";
@@ -26,14 +26,13 @@ namespace Microsoft.Plugin.Folder
public const string CopyImagePath = "Images\\copy.dark.png";
private const string _fileExplorerProgramName = "explorer";
-
private static readonly PluginJsonStorage _storage = new PluginJsonStorage();
private static readonly FolderSettings _settings = _storage.Load();
-
private static List _driverNames;
- private PluginInitContext _context;
-
+ private static PluginInitContext _context;
private IContextMenu _contextMenuLoader;
+ private static string warningIconPath;
+ private bool _disposed = false;
public void Save()
{
@@ -47,9 +46,30 @@ namespace Microsoft.Plugin.Folder
public void Init(PluginInitContext context)
{
- _context = context;
+ _context = context ?? throw new ArgumentNullException(nameof(context));
_contextMenuLoader = new ContextMenuLoader(context);
InitialDriverList();
+
+ _context.API.ThemeChanged += OnThemeChanged;
+ UpdateIconPath(_context.API.GetCurrentTheme());
+ }
+
+ private static void UpdateIconPath(Theme theme)
+ {
+ if (theme == Theme.Light || theme == Theme.HighContrastWhite)
+ {
+ warningIconPath = "Images/Warning.light.png";
+ }
+ else
+ {
+ warningIconPath = "Images/Warning.dark.png";
+ }
+ }
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1313:Parameter names should begin with lower-case letter", Justification = "The parameter is unused")]
+ private void OnThemeChanged(Theme _, Theme newTheme)
+ {
+ UpdateIconPath(newTheme);
}
[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")]
@@ -253,8 +273,28 @@ namespace Microsoft.Plugin.Folder
throw;
}
- // Initial ordering, this order can be updated later by UpdateResultView.MainViewModel based on history of user selection.
- return results.Concat(folderList.OrderBy(x => x.Title)).Concat(fileList.OrderBy(x => x.Title)).ToList();
+ results = results.Concat(folderList.OrderBy(x => x.Title).Take(_settings.MaxFolderResults)).Concat(fileList.OrderBy(x => x.Title).Take(_settings.MaxFileResults)).ToList();
+
+ // Show warning message if result has been truncated
+ if (folderList.Count > _settings.MaxFolderResults || fileList.Count > _settings.MaxFileResults)
+ {
+ var preTruncationCount = folderList.Count + fileList.Count;
+ var postTruncationCount = Math.Min(folderList.Count, _settings.MaxFolderResults) + Math.Min(fileList.Count, _settings.MaxFileResults);
+ results.Add(CreateTruncatedItemsResult(search, preTruncationCount, postTruncationCount));
+ }
+
+ return results.ToList();
+ }
+
+ private static Result CreateTruncatedItemsResult(string search, int preTruncationCount, int postTruncationCount)
+ {
+ return new Result
+ {
+ Title = _context.API.GetTranslation("Microsoft_plugin_folder_truncation_warning_title"),
+ QueryTextDisplay = search,
+ SubTitle = string.Format(CultureInfo.InvariantCulture, _context.API.GetTranslation("Microsoft_plugin_folder_truncation_warning_subtitle"), postTruncationCount, preTruncationCount),
+ IcoPath = warningIconPath,
+ };
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "We want to keep the process alve and instead inform the user of the error")]
@@ -330,5 +370,23 @@ namespace Microsoft.Plugin.Folder
public void UpdateSettings(PowerLauncherSettings settings)
{
}
+
+ public void Dispose()
+ {
+ Dispose(disposing: true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposed)
+ {
+ if (disposing)
+ {
+ _context.API.ThemeChanged -= OnThemeChanged;
+ _disposed = true;
+ }
+ }
+ }
}
}
diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Microsoft.Plugin.Folder.csproj b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Microsoft.Plugin.Folder.csproj
index 0de29244ba..93365f1560 100644
--- a/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Microsoft.Plugin.Folder.csproj
+++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Folder/Microsoft.Plugin.Folder.csproj
@@ -134,6 +134,12 @@
PreserveNewest
+
+ PreserveNewest
+
+
+ PreserveNewest
+