mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge tag 'v1.3.524+JJW24.v1.26.13'
This commit is contained in:
commit
f3a1e09042
9 changed files with 88 additions and 41 deletions
|
|
@ -41,21 +41,13 @@ namespace Wox.Plugin.Program.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Please follow exception format, there are four parts to an error message that need to be specified:
|
/// Logs an exception
|
||||||
/// |class name|calling method name|loading program path|user friendly message that explains the error
|
|
||||||
/// => Example: |Win32|LnkProgram|c:\..\chrome.exe|Permission denied on directory, but Wox should continue
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||||
internal static void LogException(string message, Exception e)
|
internal static void LogException(string classname, string callingMethodName, string loadingProgramPath,
|
||||||
|
string interpretationMessage, Exception e)
|
||||||
{
|
{
|
||||||
//Index 0 is always empty.
|
Debug.WriteLine($"ERROR{classname}|{callingMethodName}|{loadingProgramPath}|{interpretationMessage}");
|
||||||
var parts = message.Split('|');
|
|
||||||
var classname = parts[1];
|
|
||||||
var callingMethodName = parts[2];
|
|
||||||
var loadingProgramPath = parts[3];
|
|
||||||
var interpretationMessage = parts[4];
|
|
||||||
|
|
||||||
Debug.WriteLine($"ERROR{message}");
|
|
||||||
|
|
||||||
var logger = LogManager.GetLogger("");
|
var logger = LogManager.GetLogger("");
|
||||||
|
|
||||||
|
|
@ -79,16 +71,16 @@ namespace Wox.Plugin.Program.Logger
|
||||||
calledMethod = string.IsNullOrEmpty(calledMethod) ? "Not available" : calledMethod;
|
calledMethod = string.IsNullOrEmpty(calledMethod) ? "Not available" : calledMethod;
|
||||||
|
|
||||||
logger.Error($"\nException full name: {e.GetType().FullName}"
|
logger.Error($"\nException full name: {e.GetType().FullName}"
|
||||||
+ $"\nError status: {errorStatus}"
|
+ $"\nError status: {errorStatus}"
|
||||||
+ $"\nClass name: {classname}"
|
+ $"\nClass name: {classname}"
|
||||||
+ $"\nCalling method: {callingMethodName}"
|
+ $"\nCalling method: {callingMethodName}"
|
||||||
+ $"\nProgram path: {loadingProgramPath}"
|
+ $"\nProgram path: {loadingProgramPath}"
|
||||||
+ $"\nInnerException number: {innerExceptionNumber}"
|
+ $"\nInnerException number: {innerExceptionNumber}"
|
||||||
+ $"\nException message: {e.Message}"
|
+ $"\nException message: {e.Message}"
|
||||||
+ $"\nException error type: HResult {e.HResult}"
|
+ $"\nException error type: HResult {e.HResult}"
|
||||||
+ $"\nException thrown in called method: {calledMethod}"
|
+ $"\nException thrown in called method: {calledMethod}"
|
||||||
+ $"\nPossible interpretation of the error: {interpretationMessage}"
|
+ $"\nPossible interpretation of the error: {interpretationMessage}"
|
||||||
+ $"\nPossible resolution: {possibleResolution}");
|
+ $"\nPossible resolution: {possibleResolution}");
|
||||||
|
|
||||||
innerExceptionNumber++;
|
innerExceptionNumber++;
|
||||||
e = e.InnerException;
|
e = e.InnerException;
|
||||||
|
|
@ -97,6 +89,29 @@ namespace Wox.Plugin.Program.Logger
|
||||||
logger.Error("------------- END Wox.Plugin.Program exception -------------");
|
logger.Error("------------- END Wox.Plugin.Program exception -------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Please follow exception format: |class name|calling method name|loading program path|user friendly message that explains the error
|
||||||
|
/// => Example: |Win32|LnkProgram|c:\..\chrome.exe|Permission denied on directory, but Wox should continue
|
||||||
|
/// </summary>
|
||||||
|
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||||
|
internal static void LogException(string message, Exception e)
|
||||||
|
{
|
||||||
|
//Index 0 is always empty.
|
||||||
|
var parts = message.Split('|');
|
||||||
|
if (parts.Length < 4)
|
||||||
|
{
|
||||||
|
var logger = LogManager.GetLogger("");
|
||||||
|
logger.Error(e, $"fail to log exception in program logger, parts length is too small: {parts.Length}, message: {message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
var classname = parts[1];
|
||||||
|
var callingMethodName = parts[2];
|
||||||
|
var loadingProgramPath = parts[3];
|
||||||
|
var interpretationMessage = parts[4];
|
||||||
|
|
||||||
|
LogException(classname, callingMethodName, loadingProgramPath, interpretationMessage, e);
|
||||||
|
}
|
||||||
|
|
||||||
private static bool IsKnownWinProgramError(Exception e, string callingMethodName)
|
private static bool IsKnownWinProgramError(Exception e, string callingMethodName)
|
||||||
{
|
{
|
||||||
if (e.TargetSite?.Name == "GetDescription" && callingMethodName == "LnkProgram")
|
if (e.TargetSite?.Name == "GetDescription" && callingMethodName == "LnkProgram")
|
||||||
|
|
|
||||||
|
|
@ -90,9 +90,10 @@ namespace Wox.Plugin.Program
|
||||||
|
|
||||||
public static void IndexWin32Programs()
|
public static void IndexWin32Programs()
|
||||||
{
|
{
|
||||||
|
var win32S = Win32.All(_settings);
|
||||||
lock (IndexLock)
|
lock (IndexLock)
|
||||||
{
|
{
|
||||||
_win32s = Win32.All(_settings);
|
_win32s = win32S;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,17 +102,18 @@ namespace Wox.Plugin.Program
|
||||||
var windows10 = new Version(10, 0);
|
var windows10 = new Version(10, 0);
|
||||||
var support = Environment.OSVersion.Version.Major >= windows10.Major;
|
var support = Environment.OSVersion.Version.Major >= windows10.Major;
|
||||||
|
|
||||||
|
var applications = support ? UWP.All() : new UWP.Application[] { };
|
||||||
lock (IndexLock)
|
lock (IndexLock)
|
||||||
{
|
{
|
||||||
_uwps = support ? UWP.All() : new UWP.Application[] { };
|
_uwps = applications;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void IndexPrograms()
|
public static void IndexPrograms()
|
||||||
{
|
{
|
||||||
var t1 = Task.Run(() => { IndexWin32Programs(); });
|
var t1 = Task.Run(()=>IndexWin32Programs());
|
||||||
|
|
||||||
var t2 = Task.Run(() => { IndexUWPPrograms(); });
|
var t2 = Task.Run(()=>IndexUWPPrograms());
|
||||||
|
|
||||||
Task.WaitAll(t1, t2);
|
Task.WaitAll(t1, t2);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -165,9 +165,9 @@ namespace Wox.Plugin.Program.Programs
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if DEBUG //make developer aware and implement handling
|
#if DEBUG //make developer aware and implement handling
|
||||||
catch(Exception e)
|
catch
|
||||||
{
|
{
|
||||||
throw e;
|
throw;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return u.Apps;
|
return u.Apps;
|
||||||
|
|
@ -207,7 +207,7 @@ namespace Wox.Plugin.Program.Programs
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException("|UWP|CurrentUserPackages|Not available|An unexpected error occured and "
|
ProgramLogger.LogException("UWP" ,"CurrentUserPackages", $"id","An unexpected error occured and "
|
||||||
+ $"unable to verify if package is valid", e);
|
+ $"unable to verify if package is valid", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -230,8 +230,7 @@ namespace Wox.Plugin.Program.Programs
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
var uwp = obj as UWP;
|
if (obj is UWP uwp)
|
||||||
if (uwp != null)
|
|
||||||
{
|
{
|
||||||
return FamilyName.Equals(uwp.FamilyName);
|
return FamilyName.Equals(uwp.FamilyName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using hyjiacan.util.p4n;
|
||||||
using hyjiacan.util.p4n.format;
|
using hyjiacan.util.p4n.format;
|
||||||
using Wox.Infrastructure.Logger;
|
using Wox.Infrastructure.Logger;
|
||||||
using Wox.Infrastructure.Storage;
|
using Wox.Infrastructure.Storage;
|
||||||
|
using Wox.Infrastructure.UserSettings;
|
||||||
|
|
||||||
namespace Wox.Infrastructure
|
namespace Wox.Infrastructure
|
||||||
{
|
{
|
||||||
|
|
@ -14,9 +15,11 @@ namespace Wox.Infrastructure
|
||||||
private static readonly HanyuPinyinOutputFormat Format = new HanyuPinyinOutputFormat();
|
private static readonly HanyuPinyinOutputFormat Format = new HanyuPinyinOutputFormat();
|
||||||
private static ConcurrentDictionary<string, string[][]> PinyinCache;
|
private static ConcurrentDictionary<string, string[][]> PinyinCache;
|
||||||
private static BinaryStorage<ConcurrentDictionary<string, string[][]>> _pinyinStorage;
|
private static BinaryStorage<ConcurrentDictionary<string, string[][]>> _pinyinStorage;
|
||||||
|
private static Settings _settings;
|
||||||
|
|
||||||
public static void Initialize()
|
public static void Initialize(Settings settings)
|
||||||
{
|
{
|
||||||
|
_settings = settings;
|
||||||
Format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
|
Format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
|
||||||
|
|
||||||
Stopwatch.Normal("|Wox.Infrastructure.Alphabet.Initialize|Preload pinyin cache", () =>
|
Stopwatch.Normal("|Wox.Infrastructure.Alphabet.Initialize|Preload pinyin cache", () =>
|
||||||
|
|
@ -34,12 +37,20 @@ namespace Wox.Infrastructure
|
||||||
_pinyinStorage.Save(PinyinCache);
|
_pinyinStorage.Save(PinyinCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string[] EmptyStringArray = new string[0];
|
||||||
|
private static string[][] Empty2DStringArray = new string[0][];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// replace chinese character with pinyin, non chinese character won't be modified
|
/// replace chinese character with pinyin, non chinese character won't be modified
|
||||||
/// <param name="word"> should be word or sentence, instead of single character. e.g. 微软 </param>
|
/// <param name="word"> should be word or sentence, instead of single character. e.g. 微软 </param>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string[] Pinyin(string word)
|
public static string[] Pinyin(string word)
|
||||||
{
|
{
|
||||||
|
if (!_settings.ShouldUsePinyin)
|
||||||
|
{
|
||||||
|
return EmptyStringArray;
|
||||||
|
}
|
||||||
|
|
||||||
var pinyin = word.Select(c =>
|
var pinyin = word.Select(c =>
|
||||||
{
|
{
|
||||||
var pinyins = PinyinHelper.toHanyuPinyinStringArray(c);
|
var pinyins = PinyinHelper.toHanyuPinyinStringArray(c);
|
||||||
|
|
@ -57,7 +68,7 @@ namespace Wox.Infrastructure
|
||||||
/// </summmary>
|
/// </summmary>
|
||||||
public static string[][] PinyinComination(string characters)
|
public static string[][] PinyinComination(string characters)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(characters))
|
if (_settings.ShouldUsePinyin && !string.IsNullOrEmpty(characters))
|
||||||
{
|
{
|
||||||
if (!PinyinCache.ContainsKey(characters))
|
if (!PinyinCache.ContainsKey(characters))
|
||||||
{
|
{
|
||||||
|
|
@ -89,7 +100,7 @@ namespace Wox.Infrastructure
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new string[][] { };
|
return Empty2DStringArray;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,6 +112,17 @@ namespace Wox.Infrastructure
|
||||||
|
|
||||||
public static bool ContainsChinese(string word)
|
public static bool ContainsChinese(string word)
|
||||||
{
|
{
|
||||||
|
if (!_settings.ShouldUsePinyin)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (word.Length > 40)
|
||||||
|
{
|
||||||
|
Log.Debug($"|Wox.Infrastructure.StringMatcher.ScoreForPinyin|skip too long string: {word}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var chinese = word.Select(PinyinHelper.toHanyuPinyinStringArray)
|
var chinese = word.Select(PinyinHelper.toHanyuPinyinStringArray)
|
||||||
.Any(p => p != null);
|
.Any(p => p != null);
|
||||||
return chinese;
|
return chinese;
|
||||||
|
|
@ -108,6 +130,11 @@ namespace Wox.Infrastructure
|
||||||
|
|
||||||
private static string[] Combination(string[] array1, string[] array2)
|
private static string[] Combination(string[] array1, string[] array2)
|
||||||
{
|
{
|
||||||
|
if (!_settings.ShouldUsePinyin)
|
||||||
|
{
|
||||||
|
return EmptyStringArray;
|
||||||
|
}
|
||||||
|
|
||||||
var combination = (
|
var combination = (
|
||||||
from a1 in array1
|
from a1 in array1
|
||||||
from a2 in array2
|
from a2 in array2
|
||||||
|
|
|
||||||
|
|
@ -131,12 +131,6 @@ namespace Wox.Infrastructure
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(target))
|
if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(target))
|
||||||
{
|
{
|
||||||
if(source.Length > 40)
|
|
||||||
{
|
|
||||||
Log.Debug($"|Wox.Infrastructure.StringMatcher.ScoreForPinyin|skip too long string: {source}");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Alphabet.ContainsChinese(source))
|
if (Alphabet.ContainsChinese(source))
|
||||||
{
|
{
|
||||||
var combination = Alphabet.PinyinComination(source);
|
var combination = Alphabet.PinyinComination(source);
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,11 @@ namespace Wox.Infrastructure.UserSettings
|
||||||
public string ResultFontWeight { get; set; }
|
public string ResultFontWeight { get; set; }
|
||||||
public string ResultFontStretch { get; set; }
|
public string ResultFontStretch { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// when false Alphabet static service will always return empty results
|
||||||
|
/// </summary>
|
||||||
|
public bool ShouldUsePinyin { get; set; } = true;
|
||||||
|
|
||||||
private string _querySearchPrecision { get; set; } = StringMatcher.SearchPrecisionScore.Regular.ToString();
|
private string _querySearchPrecision { get; set; } = StringMatcher.SearchPrecisionScore.Regular.ToString();
|
||||||
public string QuerySearchPrecision
|
public string QuerySearchPrecision
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,12 @@ namespace Wox
|
||||||
RegisterDispatcherUnhandledException();
|
RegisterDispatcherUnhandledException();
|
||||||
|
|
||||||
ImageLoader.Initialize();
|
ImageLoader.Initialize();
|
||||||
Alphabet.Initialize();
|
|
||||||
|
|
||||||
_settingsVM = new SettingWindowViewModel();
|
_settingsVM = new SettingWindowViewModel();
|
||||||
_settings = _settingsVM.Settings;
|
_settings = _settingsVM.Settings;
|
||||||
|
|
||||||
|
Alphabet.Initialize(_settings);
|
||||||
|
|
||||||
StringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision;
|
StringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision;
|
||||||
|
|
||||||
PluginManager.LoadPlugins(_settings.PluginSettings);
|
PluginManager.LoadPlugins(_settings.PluginSettings);
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
<system:String x:Key="hideOnStartup">Hide Wox on startup</system:String>
|
<system:String x:Key="hideOnStartup">Hide Wox on startup</system:String>
|
||||||
<system:String x:Key="hideNotifyIcon">Hide tray icon</system:String>
|
<system:String x:Key="hideNotifyIcon">Hide tray icon</system:String>
|
||||||
<system:String x:Key="querySearchPrecision">Query Search Precision</system:String>
|
<system:String x:Key="querySearchPrecision">Query Search Precision</system:String>
|
||||||
|
<system:String x:Key="ShouldUsePinyin">Should Use Pinyin</system:String>
|
||||||
|
|
||||||
<!--Setting Plugin-->
|
<!--Setting Plugin-->
|
||||||
<system:String x:Key="plugin">Plugin</system:String>
|
<system:String x:Key="plugin">Plugin</system:String>
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,9 @@
|
||||||
Checked="OnAutoStartupChecked" Unchecked="OnAutoStartupUncheck">
|
Checked="OnAutoStartupChecked" Unchecked="OnAutoStartupUncheck">
|
||||||
<TextBlock Text="{DynamicResource autoUpdates}" />
|
<TextBlock Text="{DynamicResource autoUpdates}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
|
<CheckBox Margin="10" IsChecked="{Binding Settings.ShouldUsePinyin}">
|
||||||
|
<TextBlock Text="{DynamicResource ShouldUsePinyin}" />
|
||||||
|
</CheckBox>
|
||||||
<StackPanel Margin="10" Orientation="Horizontal">
|
<StackPanel Margin="10" Orientation="Horizontal">
|
||||||
<TextBlock Text="{DynamicResource querySearchPrecision}" />
|
<TextBlock Text="{DynamicResource querySearchPrecision}" />
|
||||||
<ComboBox Margin="10 0 0 0" Width="120"
|
<ComboBox Margin="10 0 0 0" Width="120"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue