resolve short freeze issue with no icon preview option

This commit is contained in:
Victor Lin 2022-01-23 18:40:21 +08:00
parent 0c05b5f363
commit ef2c587af8
7 changed files with 46 additions and 21 deletions

View File

@ -7,7 +7,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Community.PowerToys.Run.Plugin.Everything</RootNamespace>
<AssemblyName>Community.PowerToys.Run.Plugin.Everything</AssemblyName>
<Version>0.0.2.1</Version>
<Version>0.0.2.5</Version>
<useWPF>true</useWPF>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
@ -16,8 +16,8 @@
<Authors>Yu Chieh (Victor) Lin</Authors>
<Company />
<Product />
<AssemblyVersion>0.0.2.1</AssemblyVersion>
<FileVersion>0.0.2.1</FileVersion>
<AssemblyVersion>0.0.2.5</AssemblyVersion>
<FileVersion>0.0.2.5</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -103,10 +103,10 @@
<None Update="Everything64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Everything64nolock.dll">
<None Update="Images\Everything.dark.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\Everything.dark.png">
<None Update="Images\Everything.ico.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\Everything.light.png">

BIN
Images/Everything.ico.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

27
Main.cs
View File

@ -26,9 +26,11 @@ namespace Community.PowerToys.Run.Plugin.Everything
{
private const string Wait = nameof(Wait);
private const string Top = nameof(Top);
private const string NoPreview = nameof(NoPreview);
private readonly string reservedStringPattern = @"^[\/\\\$\%]+$|^.*[<>].*$";
private bool _wait;
private bool _top;
private bool _noPreview;
public string Name => Resources.plugin_name;
@ -40,7 +42,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
{
Key = Top,
DisplayLabel = Resources.Top,
Value = true,
Value = false,
},
new PluginAdditionalOption()
{
@ -48,6 +50,12 @@ namespace Community.PowerToys.Run.Plugin.Everything
DisplayLabel = Resources.Wait,
Value = false,
},
new PluginAdditionalOption()
{
Key = NoPreview,
DisplayLabel = Resources.NoPreview,
Value = false,
},
};
private IContextMenu _contextMenuLoader;
@ -63,6 +71,8 @@ namespace Community.PowerToys.Run.Plugin.Everything
}
}
private static CancellationTokenSource source;
public void Init(PluginInitContext context)
{
_context = context;
@ -91,9 +101,13 @@ namespace Community.PowerToys.Run.Plugin.Everything
if (!regexMatch.Success)
{
source?.Cancel();
source = new CancellationTokenSource();
CancellationToken token = source.Token;
source.CancelAfter(_wait ? 1000 : 75);
try
{
results.AddRange(EverythingSearch(searchQuery, _wait, _top));
results.AddRange(EverythingSearch(searchQuery, _top, _noPreview, token));
}
catch (OperationCanceledException)
{
@ -118,6 +132,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
}
catch (Exception e)
{
source.Dispose();
Log.Exception("Everything Exception", e, GetType());
}
}
@ -156,15 +171,18 @@ namespace Community.PowerToys.Run.Plugin.Everything
public void UpdateSettings(PowerLauncherPluginSettings settings)
{
var wait = false;
var top = true;
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 ?? true;
top = settings.AdditionalOptions.FirstOrDefault(x => x.Key == Top)?.Value ?? false;
nopreview = settings.AdditionalOptions.FirstOrDefault(x => x.Key == NoPreview)?.Value ?? false;
}
_top = top;
_wait = wait;
_noPreview = nopreview;
}
protected virtual void Dispose(bool disposing)
@ -173,6 +191,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
{
if (disposing)
{
source.Dispose();
}
disposed = true;

View File

@ -89,7 +89,6 @@ namespace Community.PowerToys.Run.Plugin.Everything
public static extern void Everything_SetSort(Sort SortType);
private const int max = 20;
private static CancellationTokenSource source;
#pragma warning disable SA1503 // Braces should not be omitted
public static void EverythingSetup()
{
@ -98,13 +97,8 @@ namespace Community.PowerToys.Run.Plugin.Everything
Everything_SetMax(max);
}
public static IEnumerable<Result> EverythingSearch(string qry, bool wait, bool top)
public static IEnumerable<Result> EverythingSearch(string qry, bool top, bool noPreview, CancellationToken token)
{
source?.Cancel();
source = new CancellationTokenSource();
CancellationToken token = source.Token;
source.CancelAfter(wait ? 1000 : 75);
_ = Everything_SetSearchW(qry);
if (token.IsCancellationRequested) token.ThrowIfCancellationRequested();
if (!Everything_QueryW(true))
@ -133,7 +127,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
Title = name,
ToolTipData = new ToolTipData("Name : " + name, "Path : " + path),
SubTitle = Resources.plugin_name + ": " + fullPath,
IcoPath = fullPath,
IcoPath = noPreview ? "Images/Everything.ico.png" : fullPath,
ContextData = new SearchResult()
{
Path = fullPath,

View File

@ -114,6 +114,15 @@ namespace Community.PowerToys.Run.Plugin.Everything.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Fast - Disable icon preview, fetching icons for non-local files may cause freezing..
/// </summary>
public static string NoPreview {
get {
return ResourceManager.GetString("NoPreview", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Open containing folder (Ctrl+Shift+E).
/// </summary>
@ -169,7 +178,7 @@ namespace Community.PowerToys.Run.Plugin.Everything.Properties {
}
/// <summary>
/// Looks up a localized string similar to Insert result at the top of the list..
/// Looks up a localized string similar to Top - Insert result at the top of the list..
/// </summary>
public static string Top {
get {

View File

@ -135,6 +135,9 @@
<data name="folder_open_failed" xml:space="preserve">
<value>Fail to open folder at</value>
</data>
<data name="NoPreview" xml:space="preserve">
<value>Fast - Disable icon preview, fetching icons for non-local files may cause freezing.</value>
</data>
<data name="open_containing_folder" xml:space="preserve">
<value>Open containing folder (Ctrl+Shift+E)</value>
</data>
@ -154,7 +157,7 @@
<value>Timed out before finishing the query</value>
</data>
<data name="Top" xml:space="preserve">
<value>Insert result at the top of the list.</value>
<value>Top - Insert result at the top of the list.</value>
</data>
<data name="Wait" xml:space="preserve">
<value>Wait - Wait longer for the query to finish.</value>

View File

@ -4,9 +4,9 @@
"IsGlobal": true,
"Name": "Everything",
"Author": "Yu Chieh (Victor) Lin",
"Version": "0.2.1",
"Version": "0.2.5",
"Language": "csharp",
"Website": "https://aka.ms/powertoys",
"Website": "https://github.com/lin-ycv/EverythingPowerToys",
"ExecuteFileName": "Community.PowerToys.Run.Plugin.Everything.dll",
"IcoPathDark": "Images\\Everything.dark.png",
"IcoPathLight": "Images\\Everything.light.png"