mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Mark previous api as obsolete to preserve backward compatibility.
This commit is contained in:
parent
9c13416231
commit
812703766a
4 changed files with 30 additions and 19 deletions
|
|
@ -10,31 +10,31 @@ namespace Flow.Launcher.Core.Plugin
|
|||
public static Query Build(string text, Dictionary<string, PluginPair> nonGlobalPlugins)
|
||||
{
|
||||
// replace multiple white spaces with one white space
|
||||
var textSplit = text.Split(Query.TermSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (textSplit.Length == 0)
|
||||
var terms = text.Split(Query.TermSeparator, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (terms.Length == 0)
|
||||
{ // nothing was typed
|
||||
return null;
|
||||
}
|
||||
|
||||
var rawQuery = string.Join(Query.TermSeparator, textSplit);
|
||||
var rawQuery = string.Join(Query.TermSeparator, terms);
|
||||
string actionKeyword, search;
|
||||
string possibleActionKeyword = textSplit[0];
|
||||
string[] terms;
|
||||
string possibleActionKeyword = terms[0];
|
||||
string[] searchTerms;
|
||||
|
||||
if (nonGlobalPlugins.TryGetValue(possibleActionKeyword, out var pluginPair) && !pluginPair.Metadata.Disabled)
|
||||
{ // use non global plugin for query
|
||||
actionKeyword = possibleActionKeyword;
|
||||
search = textSplit.Length > 1 ? rawQuery[(actionKeyword.Length + 1)..] : string.Empty;
|
||||
terms = textSplit[1..];
|
||||
search = terms.Length > 1 ? rawQuery[(actionKeyword.Length + 1)..] : string.Empty;
|
||||
searchTerms = terms[1..];
|
||||
}
|
||||
else
|
||||
{ // non action keyword
|
||||
actionKeyword = string.Empty;
|
||||
search = rawQuery;
|
||||
terms = textSplit;
|
||||
searchTerms = terms;
|
||||
}
|
||||
|
||||
var query = new Query(rawQuery, search, terms, actionKeyword);
|
||||
var query = new Query(rawQuery, search,terms, searchTerms, actionKeyword);
|
||||
|
||||
return query;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ namespace Flow.Launcher.Plugin
|
|||
/// <summary>
|
||||
/// to allow unit tests for plug ins
|
||||
/// </summary>
|
||||
public Query(string rawQuery, string search, string[] terms, string actionKeyword = "")
|
||||
public Query(string rawQuery, string search, string[] terms, string[] searchTerms, string actionKeyword = "")
|
||||
{
|
||||
Search = search;
|
||||
RawQuery = rawQuery;
|
||||
Terms = terms;
|
||||
SearchTerms = searchTerms;
|
||||
ActionKeyword = actionKeyword;
|
||||
}
|
||||
|
||||
|
|
@ -35,18 +35,31 @@ namespace Flow.Launcher.Plugin
|
|||
public string Search { get; internal init; }
|
||||
|
||||
/// <summary>
|
||||
/// The raw query splited into a string array.
|
||||
/// The search string split into a string array.
|
||||
/// </summary>
|
||||
public string[] SearchTerms { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The raw query split into a string array
|
||||
/// </summary>
|
||||
[Obsolete("It may or may not include action keyword, which can be confusing. Use SearchTerms instead")]
|
||||
public string[] Terms { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Query can be splited into multiple terms by whitespace
|
||||
/// </summary>
|
||||
public const string TermSeparator = " ";
|
||||
|
||||
[Obsolete("Typo")]
|
||||
public const string TermSeperater = TermSeparator;
|
||||
/// <summary>
|
||||
/// User can set multiple action keywords seperated by ';'
|
||||
/// </summary>
|
||||
public const string ActionKeywordSeparator = ";";
|
||||
|
||||
[Obsolete("Typo")]
|
||||
public const string ActionKeywordSeperater = ActionKeywordSeparator;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// '*' is used for System Plugin
|
||||
|
|
@ -65,7 +78,7 @@ namespace Flow.Launcher.Plugin
|
|||
/// <summary>
|
||||
/// strings from second search (including) to last search
|
||||
/// </summary>
|
||||
public string SecondToEndSearch => _secondToEndSearch ??= string.Join(' ', Terms.AsMemory(2));
|
||||
public string SecondToEndSearch => _secondToEndSearch ??= string.Join(' ', SearchTerms.AsMemory(2));
|
||||
|
||||
/// <summary>
|
||||
/// Return second search split by space if it has
|
||||
|
|
@ -79,7 +92,7 @@ namespace Flow.Launcher.Plugin
|
|||
|
||||
private string SplitSearch(int index)
|
||||
{
|
||||
return index < Terms.Length ? Terms[index] : string.Empty;
|
||||
return index < SearchTerms.Length ? SearchTerms[index] : string.Empty;
|
||||
}
|
||||
|
||||
public override string ToString() => RawQuery;
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ namespace Flow.Launcher.Plugin.PluginIndicator
|
|||
{
|
||||
// if query contains more than one word, eg. github tips
|
||||
// user has decided to type something else rather than wanting to see the available action keywords
|
||||
if (query.Terms.Length > 1)
|
||||
if (query.SearchTerms.Length > 1)
|
||||
return new List<Result>();
|
||||
|
||||
var results = from keyword in PluginManager.NonGlobalPlugins.Keys
|
||||
where keyword.StartsWith(query.Terms[0])
|
||||
where keyword.StartsWith(query.SearchTerms[0])
|
||||
let metadata = PluginManager.NonGlobalPlugins[keyword].Metadata
|
||||
where !metadata.Disabled
|
||||
select new Result
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller
|
|||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
var termToSearch = query.Terms.Length <= 1
|
||||
? null
|
||||
: string.Join(Plugin.Query.TermSeparator, query.Terms.Skip(1)).ToLower();
|
||||
var termToSearch = query.Search;
|
||||
|
||||
var processlist = processHelper.GetMatchingProcesses(termToSearch);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue