fix regressive issues

This commit is contained in:
qianlifeng 2015-02-06 18:13:22 +08:00
parent 02e22e5781
commit 998eecb94d
5 changed files with 33 additions and 11 deletions

View File

@ -10,16 +10,20 @@ using Wox.Plugin.WebSearch.SuggestionSources;
namespace Wox.Plugin.WebSearch namespace Wox.Plugin.WebSearch
{ {
public class WebQueryPlugin : IPlugin, ISettingProvider, IPluginI18n, IInstantQuery, IExclusiveQuery public class WebSearchPlugin : IPlugin, ISettingProvider, IPluginI18n, IInstantQuery, IExclusiveQuery
{ {
private PluginInitContext context; private PluginInitContext context;
public List<Result> Query(Query query) public List<Result> Query(Query query)
{ {
List<Result> results = new List<Result>(); List<Result> results = new List<Result>();
if (!query.Search.Contains(' '))
{
return results;
}
WebSearch webSearch = 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) if (webSearch != null)
{ {

View File

@ -67,6 +67,9 @@
<Compile Include="WebSearchStorage.cs" /> <Compile Include="WebSearchStorage.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Images\websearch\pictures.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="Languages\en.xaml"> <Content Include="Languages\en.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>

View File

@ -131,7 +131,7 @@ namespace Wox.Core.Plugin
} }
/// <summary> /// <summary>
/// Check if a query contains action keyword /// Check if a query contains valid action keyword
/// </summary> /// </summary>
/// <param name="query"></param> /// <param name="query"></param>
/// <returns></returns> /// <returns></returns>
@ -144,7 +144,19 @@ namespace Wox.Core.Plugin
var actionKeyword = strings[0].Trim(); var actionKeyword = strings[0].Trim();
if (string.IsNullOrEmpty(actionKeyword)) return false; 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) public static bool IsGenericPlugin(PluginMetadata metadata)
@ -292,15 +304,17 @@ namespace Wox.Core.Plugin
internal static PluginPair GetActionKeywordPlugin(Query query) internal static PluginPair GetActionKeywordPlugin(Query query)
{ {
PluginPair exclusivePluginPair = AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.GetActionKeyword()); PluginPair actionKeywordPluginPair = AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.GetActionKeyword());
if (exclusivePluginPair != null) if (actionKeywordPluginPair != null)
{ {
var customizedPluginConfig = UserSettingStorage.Instance. var customizedPluginConfig = UserSettingStorage.Instance.
CustomizedPluginConfigs.FirstOrDefault(o => o.ID == exclusivePluginPair.Metadata.ID); CustomizedPluginConfigs.FirstOrDefault(o => o.ID == actionKeywordPluginPair.Metadata.ID);
if (customizedPluginConfig != null && !customizedPluginConfig.Disabled) if (customizedPluginConfig != null && customizedPluginConfig.Disabled)
{ {
return exclusivePluginPair; return null;
} }
return actionKeywordPluginPair;
} }
return null; return null;

View File

@ -13,8 +13,8 @@ namespace Wox.Plugin
/// <summary> /// <summary>
/// Search part of a query. /// 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. /// 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 regular plugin to system plugin, so this property will always give you the "real" query part of /// 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 /// the query
/// </summary> /// </summary>
public string Search { get; internal set; } public string Search { get; internal set; }

View File

@ -31,6 +31,7 @@ namespace Wox.Test
Assert.IsFalse(urlPlugin.IsURL("wwww")); Assert.IsFalse(urlPlugin.IsURL("wwww"));
Assert.IsFalse(urlPlugin.IsURL("wwww.c")); Assert.IsFalse(urlPlugin.IsURL("wwww.c"));
Assert.IsFalse(urlPlugin.IsURL("wwww.c"));
} }
} }
} }