From b7e6d352e4967cadf060911e9465983d4dd5654c Mon Sep 17 00:00:00 2001 From: bao-qian Date: Tue, 19 May 2020 15:17:54 +0800 Subject: [PATCH 1/8] dynamic check pinyin setting --- Wox.Infrastructure/Alphabet.cs | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/Wox.Infrastructure/Alphabet.cs b/Wox.Infrastructure/Alphabet.cs index df31ef8c5..47a530f10 100644 --- a/Wox.Infrastructure/Alphabet.cs +++ b/Wox.Infrastructure/Alphabet.cs @@ -25,23 +25,30 @@ public void Initialize() public string Translate(string content) { - string result = _cache[content] as string; - if (result == null) + if (_settings.ShouldUsePinyin) { - if (_settings.ShouldUsePinyin && WordsHelper.HasChinese(content)) + string result = _cache[content] as string; + if (result == null) { - // todo change first pinyin to full pinyin list, but current fuzzy match algorithm won't support first char match - result = WordsHelper.GetFirstPinyin(content); + if (WordsHelper.HasChinese(content)) + { + // todo change first pinyin to full pinyin list, but current fuzzy match algorithm won't support first char match + result = WordsHelper.GetFirstPinyin(content); + } + else + { + result = content; + } + CacheItemPolicy policy = new CacheItemPolicy(); + policy.SlidingExpiration = new TimeSpan(12, 0, 0); + _cache.Set(content, result, policy); } - else - { - result = content; - } - CacheItemPolicy policy = new CacheItemPolicy(); - policy.SlidingExpiration = new TimeSpan(12, 0, 0); - _cache.Set(content, result, policy); + return result; + } + else + { + return content; } - return result; } } } From d1eb884d18bdaf02eb287cd455a1f85c8d59de6b Mon Sep 17 00:00:00 2001 From: bao-qian Date: Tue, 19 May 2020 19:16:38 +0800 Subject: [PATCH 2/8] fix uwp OneConnect --- Plugins/Wox.Plugin.Program/Programs/UWP.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Wox.Plugin.Program/Programs/UWP.cs b/Plugins/Wox.Plugin.Program/Programs/UWP.cs index dd4b0d241..bc5660455 100644 --- a/Plugins/Wox.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Wox.Plugin.Program/Programs/UWP.cs @@ -382,7 +382,7 @@ internal string ResourcesFromPri(string packageFullName, String packageName, str key = $"/{key}"; } - if (!key.ToLower().Contains("resources") && key.Count(c => c == '/') <= 3) + if (!key.ToLower().Contains("resources") && key.Count(c => c == '/') < 3) { key = $"/Resources{key}"; } From 9033e5eb8bdd1fe5da5ac6967df1d62e890275c8 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Tue, 19 May 2020 19:36:38 +0800 Subject: [PATCH 3/8] fix uwp 28671Petrroll.PowerPlanSwitcher_0.4.4.0_x86__ge82akyxbc7z4 --- Plugins/Wox.Plugin.Program/Programs/UWP.cs | 35 ++++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/Plugins/Wox.Plugin.Program/Programs/UWP.cs b/Plugins/Wox.Plugin.Program/Programs/UWP.cs index bc5660455..5fb2fc421 100644 --- a/Plugins/Wox.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Wox.Plugin.Program/Programs/UWP.cs @@ -350,12 +350,12 @@ public Application(IAppxManifestApplication manifestApp, UWP package) DisplayName = ResourcesFromPri(package.FullName, package.Name, DisplayName); Description = ResourcesFromPri(package.FullName, package.Name, Description); LogoUri = LogoUriFromManifest(manifestApp); - LogoPath = FilesFromPri(package.FullName, package.Name, LogoUri); + LogoPath = PathFromUri(package.FullName, package.Name, package.Location, LogoUri); Enabled = true; } - internal string ResourcesFromPri(string packageFullName, String packageName, string resourceReference) + internal string ResourcesFromPri(string packageFullName, string packageName, string resourceReference) { const string prefix = "ms-resource:"; string result = ""; @@ -409,7 +409,7 @@ internal string ResourcesFromPri(string packageFullName, String packageName, str return result; } - private string FilesFromPri(string packageFullName, string packageName, string fileReference) + private string PathFromUri(string packageFullName, string packageName, string packageLocation, string fileReference) { // all https://msdn.microsoft.com/windows/uwp/controls-and-patterns/tiles-and-notifications-app-assets // windows 10 https://msdn.microsoft.com/en-us/library/windows/apps/dn934817.aspx @@ -417,19 +417,28 @@ private string FilesFromPri(string packageFullName, string packageName, string f // windows 8 https://msdn.microsoft.com/en-us/library/windows/apps/br211475.aspx Logger.WoxTrace($"package: <{packageFullName}> file ref: <{fileReference}>"); - string parsed = $"ms-resource://{packageName}/Files/{fileReference.Replace("\\", "/")}"; - try + string path = Path.Combine(packageLocation, fileReference); + if (File.Exists(path)) { - string result = ResourceFromPriInternal(packageFullName, parsed); - Logger.WoxTrace($"package: <{packageFullName}> pri file result: <{result}>"); - return result; + // for 28671Petrroll.PowerPlanSwitcher_0.4.4.0_x86__ge82akyxbc7z4 + return path; } - catch (Exception e) + else { - e.Data.Add(nameof(fileReference), fileReference); - e.Data.Add(nameof(FilesFromPri) + nameof(parsed), parsed); - e.Data.Add(nameof(FilesFromPri) + nameof(packageFullName), packageFullName); - throw e; + string parsed = $"ms-resource://{packageName}/Files/{fileReference.Replace("\\", "/")}"; + try + { + string result = ResourceFromPriInternal(packageFullName, parsed); + Logger.WoxTrace($"package: <{packageFullName}> pri file result: <{result}>"); + return result; + } + catch (Exception e) + { + e.Data.Add(nameof(fileReference), fileReference); + e.Data.Add(nameof(PathFromUri) + nameof(parsed), parsed); + e.Data.Add(nameof(PathFromUri) + nameof(packageFullName), packageFullName); + throw e; + } } } From c3e532896a9e2d67a85e903fcf70b604111c323f Mon Sep 17 00:00:00 2001 From: bao-qian Date: Tue, 19 May 2020 20:09:42 +0800 Subject: [PATCH 4/8] pass variable explictly --- Wox/ViewModel/SettingWindowViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Wox/ViewModel/SettingWindowViewModel.cs b/Wox/ViewModel/SettingWindowViewModel.cs index 7c6fccd16..9a7832ee0 100644 --- a/Wox/ViewModel/SettingWindowViewModel.cs +++ b/Wox/ViewModel/SettingWindowViewModel.cs @@ -52,7 +52,7 @@ public async void UpdateApp() } else { - await _updater.UpdateApp(false); + await _updater.UpdateApp(false, Settings.UpdateToPrereleases); } } From af0a68f8eb4472af0e58b82232782086f6f85aa2 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Tue, 19 May 2020 20:10:08 +0800 Subject: [PATCH 5/8] fix release upload and upload dependency automatically --- appveyor.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 57dffb9d2..cd566c57e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,3 +26,8 @@ artifacts: - path: 'Output\Packages\Wox-*.*' name: installer - path: 'Output\Packages\RELEASES' + name: installer + - path: 'Wox.Installer\Everything*.exe' + name: installer + - path: 'Wox.Installer\python*.exe' + name: installer From a094b8f488991f192f2fbea83164baf8b37f0484 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Tue, 19 May 2020 20:20:43 +0800 Subject: [PATCH 6/8] fix WebSearch duplicate result #2961 https://github.com/Wox-launcher/Wox/pull/2961 --- Plugins/Wox.Plugin.WebSearch/Main.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Plugins/Wox.Plugin.WebSearch/Main.cs b/Plugins/Wox.Plugin.WebSearch/Main.cs index b5eae6da2..dfd5a8e6b 100644 --- a/Plugins/Wox.Plugin.WebSearch/Main.cs +++ b/Plugins/Wox.Plugin.WebSearch/Main.cs @@ -89,12 +89,6 @@ public List Query(Query query) }; results.Add(result); - ResultsUpdated?.Invoke(this, new ResultUpdatedEventArgs - { - Results = results, - Query = query - }); - UpdateResultsFromSuggestion(results, keyword, subtitle, searchSource, query); } } From 8740c67b9b141548fe858765039f44072266b7ed Mon Sep 17 00:00:00 2001 From: bao-qian Date: Tue, 19 May 2020 21:21:48 +0800 Subject: [PATCH 7/8] temp fix for memory leak --- Wox.Infrastructure/Alphabet.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Wox.Infrastructure/Alphabet.cs b/Wox.Infrastructure/Alphabet.cs index 47a530f10..a9b9da276 100644 --- a/Wox.Infrastructure/Alphabet.cs +++ b/Wox.Infrastructure/Alphabet.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Specialized; +using System.Diagnostics; using System.Linq; using System.Runtime.Caching; using NLog; using ToolGood.Words; +using Wox.Infrastructure.Logger; using Wox.Infrastructure.UserSettings; namespace Wox.Infrastructure @@ -12,6 +14,9 @@ public class Alphabet { private Settings _settings; private MemoryCache _cache; + + private static readonly NLog.Logger Logger = LogManager.GetCurrentClassLogger(); + private static int count = 0; public void Initialize() { @@ -30,10 +35,20 @@ public string Translate(string content) string result = _cache[content] as string; if (result == null) { + if (count == 50) + { + // https://github.com/toolgood/ToolGood.Words/issues/53 + GC.Collect(); + } + if (WordsHelper.HasChinese(content)) { // todo change first pinyin to full pinyin list, but current fuzzy match algorithm won't support first char match result = WordsHelper.GetFirstPinyin(content); + if (count < 50) + { + count += 1; + } } else { From 52ecd848da507dad235a3d939307f8d244a96f60 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Tue, 19 May 2020 21:54:10 +0800 Subject: [PATCH 8/8] fix #2963 https://github.com/Wox-launcher/Wox/issues/2963 --- .../AddProgramSource.xaml.cs | 6 ++-- Plugins/Wox.Plugin.Program/ProgramSource.cs | 24 ++++++++++++++ Plugins/Wox.Plugin.Program/Programs/Win32.cs | 2 +- Plugins/Wox.Plugin.Program/Settings.cs | 17 +--------- .../Views/Models/ProgramSource.cs | 5 --- .../Views/ProgramSetting.xaml.cs | 31 ++++++------------- .../Wox.Plugin.Program.csproj | 2 +- 7 files changed, 39 insertions(+), 48 deletions(-) create mode 100644 Plugins/Wox.Plugin.Program/ProgramSource.cs delete mode 100644 Plugins/Wox.Plugin.Program/Views/Models/ProgramSource.cs diff --git a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs index f7d52d12b..3d12ac514 100644 --- a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs +++ b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs @@ -3,8 +3,6 @@ using Ookii.Dialogs.Wpf; // may be removed later https://github.com/dotnet/wpf/issues/438 -using Wox.Plugin.Program.Views.Models; -using Wox.Plugin.Program.Views; namespace Wox.Plugin.Program @@ -15,7 +13,7 @@ namespace Wox.Plugin.Program public partial class AddProgramSource { private PluginInitContext _context; - private Settings.ProgramSource _editing; + private ProgramSource _editing; private Settings _settings; public AddProgramSource(PluginInitContext context, Settings settings) @@ -26,7 +24,7 @@ public AddProgramSource(PluginInitContext context, Settings settings) Directory.Focus(); } - public AddProgramSource(Settings.ProgramSource edit, Settings settings) + public AddProgramSource(ProgramSource edit, Settings settings) { _editing = edit; _settings = settings; diff --git a/Plugins/Wox.Plugin.Program/ProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSource.cs new file mode 100644 index 000000000..5f4bbb1c4 --- /dev/null +++ b/Plugins/Wox.Plugin.Program/ProgramSource.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Wox.Plugin.Program +{ + public class ProgramSource + { + public string Location { get; set; } + + public override bool Equals(object obj) + { + var s = obj as ProgramSource; + return Location.Equals(s?.Location); + } + + public override int GetHashCode() + { + return this.Location.GetHashCode(); + } + } +} diff --git a/Plugins/Wox.Plugin.Program/Programs/Win32.cs b/Plugins/Wox.Plugin.Program/Programs/Win32.cs index 8f6fdc2b7..c11ec8a3d 100644 --- a/Plugins/Wox.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Wox.Plugin.Program/Programs/Win32.cs @@ -251,7 +251,7 @@ private static string Extension(string path) } } - private static ParallelQuery UnregisteredPrograms(List sources, string[] suffixes) + private static ParallelQuery UnregisteredPrograms(List sources, string[] suffixes) { var paths = sources.Where(s => Directory.Exists(s.Location)) .SelectMany(s => ProgramPaths(s.Location, suffixes)) diff --git a/Plugins/Wox.Plugin.Program/Settings.cs b/Plugins/Wox.Plugin.Program/Settings.cs index 556df5cb9..ef65cc70b 100644 --- a/Plugins/Wox.Plugin.Program/Settings.cs +++ b/Plugins/Wox.Plugin.Program/Settings.cs @@ -17,22 +17,7 @@ public class Settings internal const char SuffixSeperator = ';'; - public class ProgramSource - { - public string Location { get; set; } - - public override bool Equals(object obj) - { - var s = obj as ProgramSource; - var equality = s?.Location == Location ; - return equality; - } - - public override int GetHashCode() - { - return this.Location.GetHashCode(); - } - } + } } diff --git a/Plugins/Wox.Plugin.Program/Views/Models/ProgramSource.cs b/Plugins/Wox.Plugin.Program/Views/Models/ProgramSource.cs deleted file mode 100644 index c2995f74d..000000000 --- a/Plugins/Wox.Plugin.Program/Views/Models/ProgramSource.cs +++ /dev/null @@ -1,5 +0,0 @@ - -namespace Wox.Plugin.Program.Views.Models -{ - public class ProgramSource : Settings.ProgramSource { } -} diff --git a/Plugins/Wox.Plugin.Program/Views/ProgramSetting.xaml.cs b/Plugins/Wox.Plugin.Program/Views/ProgramSetting.xaml.cs index 0b404cd4c..319749b69 100644 --- a/Plugins/Wox.Plugin.Program/Views/ProgramSetting.xaml.cs +++ b/Plugins/Wox.Plugin.Program/Views/ProgramSetting.xaml.cs @@ -5,7 +5,6 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; -using Wox.Plugin.Program.Views.Models; using Wox.Plugin.Program.Programs; using System.ComponentModel; using System.Windows.Data; @@ -52,23 +51,15 @@ private void ReIndexing() private void btnAddProgramSource_OnClick(object sender, RoutedEventArgs e) { var add = new AddProgramSource(context, _settings); - if(add.ShowDialog() ?? false) + if (add.ShowDialog() ?? false) { ReIndexing(); } - - programSourceView.Items.Refresh(); - } - - private void DeleteProgramSources(List itemsToDelete) - { - _settings.ProgramSources = _settings.ProgramSources.Where(s => itemsToDelete.Contains(s)).ToList(); - ReIndexing(); } private void btnEditProgramSource_OnClick(object sender, RoutedEventArgs e) { - var selectedProgramSource = programSourceView.SelectedItem as Settings.ProgramSource; + var selectedProgramSource = programSourceView.SelectedItem as ProgramSource; if (selectedProgramSource != null) { var add = new AddProgramSource(selectedProgramSource, _settings); @@ -127,15 +118,13 @@ private void programSourceView_Drop(object sender, DragEventArgs e) Location = directory, }; - directoriesToAdd.Add(source); + directoriesToAdd.Add(source); } } if (directoriesToAdd.Count() > 0) { directoriesToAdd.ForEach(x => _settings.ProgramSources.Add(x)); - - programSourceView.Items.Refresh(); ReIndexing(); } } @@ -165,12 +154,12 @@ private void btnProgramSoureDelete_OnClick(object sender, RoutedEventArgs e) MessageBox.Show(msg); return; } - - DeleteProgramSources(selectedItems); - ReIndexing(); - - programSourceView.SelectedItems.Clear(); - programSourceView.Items.Refresh(); + else + { + _settings.ProgramSources.RemoveAll(s => selectedItems.Contains(s)); + programSourceView.SelectedItems.Clear(); + ReIndexing(); + } } private void ProgramSourceView_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e) @@ -207,7 +196,7 @@ private void GridViewColumnHeaderClickedHandler(object sender, RoutedEventArgs e var sortBy = columnBinding?.Path.Path ?? headerClicked.Column.Header as string; Sort(sortBy, direction); - + _lastHeaderClicked = headerClicked; _lastDirection = direction; } diff --git a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj index 1869abc0b..b9eeb48f5 100644 --- a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj +++ b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj @@ -70,7 +70,7 @@ AddProgramSource.xaml - +