From 998eecb94d3532dbaf86f674276ea90a715a608b Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Fri, 6 Feb 2015 18:13:22 +0800 Subject: [PATCH] fix regressive issues --- .../Wox.Plugin.WebSearch/WebQueryPlugin.cs | 8 ++++-- .../Wox.Plugin.WebSearch.csproj | 3 ++ Wox.Core/Plugin/PluginManager.cs | 28 ++++++++++++++----- Wox.Plugin/Query.cs | 4 +-- Wox.Test/UrlPluginTest.cs | 1 + 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/Plugins/Wox.Plugin.WebSearch/WebQueryPlugin.cs b/Plugins/Wox.Plugin.WebSearch/WebQueryPlugin.cs index 41636b24f6..10632094af 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebQueryPlugin.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebQueryPlugin.cs @@ -10,16 +10,20 @@ using Wox.Plugin.WebSearch.SuggestionSources; namespace Wox.Plugin.WebSearch { - public class WebQueryPlugin : IPlugin, ISettingProvider, IPluginI18n, IInstantQuery, IExclusiveQuery + public class WebSearchPlugin : IPlugin, ISettingProvider, IPluginI18n, IInstantQuery, IExclusiveQuery { private PluginInitContext context; public List Query(Query query) { List results = new List(); + if (!query.Search.Contains(' ')) + { + return results; + } WebSearch webSearch = - WebSearchStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.FirstSearch.Trim() && !string.IsNullOrEmpty(query.SecondSearch) && o.Enabled); + WebSearchStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.FirstSearch.Trim() && o.Enabled); if (webSearch != null) { diff --git a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj index 3f9a500eb1..90a2c3dccc 100644 --- a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj +++ b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj @@ -67,6 +67,9 @@ + + PreserveNewest + MSBuild:Compile Designer diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index fb13b57814..5e93bb0101 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -131,7 +131,7 @@ namespace Wox.Core.Plugin } /// - /// Check if a query contains action keyword + /// Check if a query contains valid action keyword /// /// /// @@ -144,7 +144,19 @@ namespace Wox.Core.Plugin var actionKeyword = strings[0].Trim(); if (string.IsNullOrEmpty(actionKeyword)) return false; - return plugins.Any(o => o.Metadata.ActionKeyword == actionKeyword); + PluginPair pair = plugins.FirstOrDefault(o => o.Metadata.ActionKeyword == actionKeyword); + if (pair != null) + { + var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == pair.Metadata.ID); + if (customizedPluginConfig != null && customizedPluginConfig.Disabled) + { + return false; + } + + return true; + } + + return false; } public static bool IsGenericPlugin(PluginMetadata metadata) @@ -292,15 +304,17 @@ namespace Wox.Core.Plugin internal static PluginPair GetActionKeywordPlugin(Query query) { - PluginPair exclusivePluginPair = AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.GetActionKeyword()); - if (exclusivePluginPair != null) + PluginPair actionKeywordPluginPair = AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.GetActionKeyword()); + if (actionKeywordPluginPair != null) { var customizedPluginConfig = UserSettingStorage.Instance. - CustomizedPluginConfigs.FirstOrDefault(o => o.ID == exclusivePluginPair.Metadata.ID); - if (customizedPluginConfig != null && !customizedPluginConfig.Disabled) + CustomizedPluginConfigs.FirstOrDefault(o => o.ID == actionKeywordPluginPair.Metadata.ID); + if (customizedPluginConfig != null && customizedPluginConfig.Disabled) { - return exclusivePluginPair; + return null; } + + return actionKeywordPluginPair; } return null; diff --git a/Wox.Plugin/Query.cs b/Wox.Plugin/Query.cs index dee9628773..79fe259be4 100644 --- a/Wox.Plugin/Query.cs +++ b/Wox.Plugin/Query.cs @@ -13,8 +13,8 @@ namespace Wox.Plugin /// /// Search part of a query. - /// This will not include action keyword if regular plugin gets it, and if a system plugin gets it, it should be same as RawQuery. - /// Since we allow user to switch a regular plugin to system plugin, so this property will always give you the "real" query part of + /// This will not include action keyword if exclusive plugin gets it, otherwise it should be same as RawQuery. + /// Since we allow user to switch a exclusive plugin to generic plugin, so this property will always give you the "real" query part of /// the query /// public string Search { get; internal set; } diff --git a/Wox.Test/UrlPluginTest.cs b/Wox.Test/UrlPluginTest.cs index 79f95109a2..daaa9641cb 100644 --- a/Wox.Test/UrlPluginTest.cs +++ b/Wox.Test/UrlPluginTest.cs @@ -31,6 +31,7 @@ namespace Wox.Test Assert.IsFalse(urlPlugin.IsURL("wwww")); Assert.IsFalse(urlPlugin.IsURL("wwww.c")); + Assert.IsFalse(urlPlugin.IsURL("wwww.c")); } } }