From 3ae9e161b2d9633f780a44ed390181b408ee93e6 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Sun, 26 Sep 2021 18:28:22 -0500 Subject: [PATCH] Allow keyword search --- Classes/WindowsSetting.cs | 10 ++++++++++ Flow.Plugin.WindowsSettings.sln | 25 +++++++++++++++++++++++++ Helper/ResultHelper.cs | 15 ++++++++++++++- 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 Flow.Plugin.WindowsSettings.sln diff --git a/Classes/WindowsSetting.cs b/Classes/WindowsSetting.cs index 0a598d122..4a130daf7 100644 --- a/Classes/WindowsSetting.cs +++ b/Classes/WindowsSetting.cs @@ -47,6 +47,16 @@ namespace Flow.Plugin.WindowsSettings.Classes /// public IEnumerable? AltNames { get; set; } + /// + /// Gets or sets the Keywords names of this task link. + /// + public IEnumerable>? Keywords { get; set; } + + /// + /// Gets or sets the Ghyph of this setting + /// + public string? glyph { get; set; } + /// /// Gets or sets a additional note of this settings. /// (e.g. why is not supported on your system) diff --git a/Flow.Plugin.WindowsSettings.sln b/Flow.Plugin.WindowsSettings.sln new file mode 100644 index 000000000..79ce08598 --- /dev/null +++ b/Flow.Plugin.WindowsSettings.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31512.422 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Plugin.WindowsSettings", "Flow.Plugin.WindowsSettings.csproj", "{5043CECE-E6A7-4867-9CBE-02D27D83747A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5043CECE-E6A7-4867-9CBE-02D27D83747A}.Debug|x64.ActiveCfg = Debug|x64 + {5043CECE-E6A7-4867-9CBE-02D27D83747A}.Debug|x64.Build.0 = Debug|x64 + {5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|x64.ActiveCfg = Release|x64 + {5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EA85E245-28F0-4192-B9E7-6FA8CFF3D3CD} + EndGlobalSection +EndGlobal diff --git a/Helper/ResultHelper.cs b/Helper/ResultHelper.cs index 29fcc0038..fb781e1f8 100644 --- a/Helper/ResultHelper.cs +++ b/Helper/ResultHelper.cs @@ -69,7 +69,20 @@ namespace Flow.Plugin.WindowsSettings.Helper .FirstOrDefault(); } + if (result is null && entry.Keywords is not null) + { + string[] searchKeywords = query.Terms[(string.IsNullOrEmpty(query.ActionKeyword) ? 0 : 1)..]; + + if (searchKeywords + .All(x => entry + .Keywords + .SelectMany(x => x) + .Contains(x, StringComparer.CurrentCultureIgnoreCase)) + ) + result = NewSettingResult(midScore); + } } + if (result is null) continue; @@ -82,7 +95,7 @@ namespace Flow.Plugin.WindowsSettings.Helper Action = _ => DoOpenSettingsAction(entry), IcoPath = iconPath, SubTitle = $"{Resources.Area} \"{entry.Area}\" {Resources.SubtitlePreposition} {entry.Type}", - Title = entry.Name, + Title = entry.Name + entry.glyph, ContextData = entry, Score = score };