diff --git a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs index 8044e8065..96328ba62 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.Json.Serialization; +using Windows.Foundation.Metadata; namespace Flow.Launcher.Plugin.Program { @@ -11,7 +12,10 @@ namespace Flow.Launcher.Plugin.Program public DateTime LastIndexTime { get; set; } public List ProgramSources { get; set; } = new List(); public List DisabledProgramSources { get; set; } = new List(); - public string[] CustomSuffixes { get; set; } = Array.Empty(); + + [Obsolete, JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string[] ProgramSuffixes { get; set; } = null; + public string[] CustomSuffixes { get; set; } = Array.Empty(); // Custom suffixes only public string[] CustomProtocols { get; set; } = Array.Empty(); public Dictionary BuiltinSuffixesStatus { get; set; } = new Dictionary{ @@ -32,6 +36,7 @@ namespace Flow.Launcher.Plugin.Program public string[] GetSuffixes() { + RemoveRedundantSuffixes(); List extensions = new List(); foreach (var item in BuiltinSuffixesStatus) { @@ -84,6 +89,24 @@ namespace Flow.Launcher.Plugin.Program } } + private void RemoveRedundantSuffixes() + { + // Migrate to new settings + // CustomSuffixes no longer contains custom suffixes + // users has tweaked the settings + // or this function has been executed once + if (UseCustomSuffixes == true || ProgramSuffixes == null) + return; + var suffixes = ProgramSuffixes.ToList(); + foreach(var item in BuiltinSuffixesStatus) + { + suffixes.Remove(item.Key); + } + CustomSuffixes = suffixes.ToArray(); // Custom suffixes + UseCustomSuffixes = CustomSuffixes.Length != 0; // Search custom suffixes or not + ProgramSuffixes = null; + } + public bool EnableStartMenuSource { get; set; } = true; public bool EnableDescription { get; set; } = false; public bool HideAppsPath { get; set; } = true;