diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs index 2f84fdbf58a..023eea042e6 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs @@ -378,15 +378,10 @@ public Result Result(string query, IPublicAPI api) MatchResult matchResult; // We suppose Name won't be null - if (!Main._settings.EnableDescription || Description == null || Name.StartsWith(Description)) + if (!Main._settings.EnableDescription || string.IsNullOrWhiteSpace(Description) || Name.Equals(Description)) { title = Name; - matchResult = StringMatcher.FuzzySearch(query, title); - } - else if (Description.StartsWith(Name)) - { - title = Description; - matchResult = StringMatcher.FuzzySearch(query, Description); + matchResult = StringMatcher.FuzzySearch(query, Name); } else { @@ -401,10 +396,13 @@ public Result Result(string query, IPublicAPI api) } matchResult = descriptionMatch; } - else matchResult = nameMatch; + else + { + matchResult = nameMatch; + } } - if (!matchResult.Success) + if (!matchResult.IsSearchPrecisionScoreMet()) return null; var result = new Result diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index dec43530e6c..f678b6bc89c 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -90,44 +90,28 @@ public Result Result(string query, IPublicAPI api) bool useLocalizedName = !string.IsNullOrEmpty(LocalizedName) && !Name.Equals(LocalizedName); string resultName = useLocalizedName ? LocalizedName : Name; - if (!Main._settings.EnableDescription) + if (!Main._settings.EnableDescription || string.IsNullOrWhiteSpace(Description) || resultName.Equals(Description)) { title = resultName; matchResult = StringMatcher.FuzzySearch(query, resultName); } else { - if (string.IsNullOrEmpty(Description) || resultName.StartsWith(Description)) + // Search in both + title = $"{resultName}: {Description}"; + var nameMatch = StringMatcher.FuzzySearch(query, resultName); + var descriptionMatch = StringMatcher.FuzzySearch(query, Description); + if (descriptionMatch.Score > nameMatch.Score) { - // Description is invalid or included in resultName - // Description is always localized, so Name.StartsWith(Description) is generally useless - title = resultName; - matchResult = StringMatcher.FuzzySearch(query, resultName); - } - else if (Description.StartsWith(resultName)) - { - // resultName included in Description - title = Description; - matchResult = StringMatcher.FuzzySearch(query, Description); + for (int i = 0; i < descriptionMatch.MatchData.Count; i++) + { + descriptionMatch.MatchData[i] += resultName.Length + 2; // 2 is ": " + } + matchResult = descriptionMatch; } else { - // Search in both - title = $"{resultName}: {Description}"; - var nameMatch = StringMatcher.FuzzySearch(query, resultName); - var descriptionMatch = StringMatcher.FuzzySearch(query, Description); - if (descriptionMatch.Score > nameMatch.Score) - { - for (int i = 0; i < descriptionMatch.MatchData.Count; i++) - { - descriptionMatch.MatchData[i] += resultName.Length + 2; // 2 is ": " - } - matchResult = descriptionMatch; - } - else - { - matchResult = nameMatch; - } + matchResult = nameMatch; } }