Skip to content

Commit 8127037

Browse files
committed
Mark previous api as obsolete to preserve backward compatibility.
1 parent 9c13416 commit 8127037

File tree

4 files changed

+30
-19
lines changed

4 files changed

+30
-19
lines changed

Flow.Launcher.Core/Plugin/QueryBuilder.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,31 @@ public static class QueryBuilder
1010
public static Query Build(string text, Dictionary<string, PluginPair> nonGlobalPlugins)
1111
{
1212
// replace multiple white spaces with one white space
13-
var textSplit = text.Split(Query.TermSeparator, StringSplitOptions.RemoveEmptyEntries);
14-
if (textSplit.Length == 0)
13+
var terms = text.Split(Query.TermSeparator, StringSplitOptions.RemoveEmptyEntries);
14+
if (terms.Length == 0)
1515
{ // nothing was typed
1616
return null;
1717
}
1818

19-
var rawQuery = string.Join(Query.TermSeparator, textSplit);
19+
var rawQuery = string.Join(Query.TermSeparator, terms);
2020
string actionKeyword, search;
21-
string possibleActionKeyword = textSplit[0];
22-
string[] terms;
21+
string possibleActionKeyword = terms[0];
22+
string[] searchTerms;
2323

2424
if (nonGlobalPlugins.TryGetValue(possibleActionKeyword, out var pluginPair) && !pluginPair.Metadata.Disabled)
2525
{ // use non global plugin for query
2626
actionKeyword = possibleActionKeyword;
27-
search = textSplit.Length > 1 ? rawQuery[(actionKeyword.Length + 1)..] : string.Empty;
28-
terms = textSplit[1..];
27+
search = terms.Length > 1 ? rawQuery[(actionKeyword.Length + 1)..] : string.Empty;
28+
searchTerms = terms[1..];
2929
}
3030
else
3131
{ // non action keyword
3232
actionKeyword = string.Empty;
3333
search = rawQuery;
34-
terms = textSplit;
34+
searchTerms = terms;
3535
}
3636

37-
var query = new Query(rawQuery, search, terms, actionKeyword);
37+
var query = new Query(rawQuery, search,terms, searchTerms, actionKeyword);
3838

3939
return query;
4040
}

Flow.Launcher.Plugin/Query.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ public Query() { }
1212
/// <summary>
1313
/// to allow unit tests for plug ins
1414
/// </summary>
15-
public Query(string rawQuery, string search, string[] terms, string actionKeyword = "")
15+
public Query(string rawQuery, string search, string[] terms, string[] searchTerms, string actionKeyword = "")
1616
{
1717
Search = search;
1818
RawQuery = rawQuery;
19-
Terms = terms;
19+
SearchTerms = searchTerms;
2020
ActionKeyword = actionKeyword;
2121
}
2222

@@ -35,18 +35,31 @@ public Query(string rawQuery, string search, string[] terms, string actionKeywor
3535
public string Search { get; internal init; }
3636

3737
/// <summary>
38-
/// The raw query splited into a string array.
38+
/// The search string split into a string array.
3939
/// </summary>
40+
public string[] SearchTerms { get; init; }
41+
42+
/// <summary>
43+
/// The raw query split into a string array
44+
/// </summary>
45+
[Obsolete("It may or may not include action keyword, which can be confusing. Use SearchTerms instead")]
4046
public string[] Terms { get; init; }
4147

4248
/// <summary>
4349
/// Query can be splited into multiple terms by whitespace
4450
/// </summary>
4551
public const string TermSeparator = " ";
52+
53+
[Obsolete("Typo")]
54+
public const string TermSeperater = TermSeparator;
4655
/// <summary>
4756
/// User can set multiple action keywords seperated by ';'
4857
/// </summary>
4958
public const string ActionKeywordSeparator = ";";
59+
60+
[Obsolete("Typo")]
61+
public const string ActionKeywordSeperater = ActionKeywordSeparator;
62+
5063

5164
/// <summary>
5265
/// '*' is used for System Plugin
@@ -65,7 +78,7 @@ public Query(string rawQuery, string search, string[] terms, string actionKeywor
6578
/// <summary>
6679
/// strings from second search (including) to last search
6780
/// </summary>
68-
public string SecondToEndSearch => _secondToEndSearch ??= string.Join(' ', Terms.AsMemory(2));
81+
public string SecondToEndSearch => _secondToEndSearch ??= string.Join(' ', SearchTerms.AsMemory(2));
6982

7083
/// <summary>
7184
/// Return second search split by space if it has
@@ -79,7 +92,7 @@ public Query(string rawQuery, string search, string[] terms, string actionKeywor
7992

8093
private string SplitSearch(int index)
8194
{
82-
return index < Terms.Length ? Terms[index] : string.Empty;
95+
return index < SearchTerms.Length ? SearchTerms[index] : string.Empty;
8396
}
8497

8598
public override string ToString() => RawQuery;

Plugins/Flow.Launcher.Plugin.PluginIndicator/Main.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ public List<Result> Query(Query query)
1212
{
1313
// if query contains more than one word, eg. github tips
1414
// user has decided to type something else rather than wanting to see the available action keywords
15-
if (query.Terms.Length > 1)
15+
if (query.SearchTerms.Length > 1)
1616
return new List<Result>();
1717

1818
var results = from keyword in PluginManager.NonGlobalPlugins.Keys
19-
where keyword.StartsWith(query.Terms[0])
19+
where keyword.StartsWith(query.SearchTerms[0])
2020
let metadata = PluginManager.NonGlobalPlugins[keyword].Metadata
2121
where !metadata.Disabled
2222
select new Result

Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ public void Init(PluginInitContext context)
2323

2424
public List<Result> Query(Query query)
2525
{
26-
var termToSearch = query.Terms.Length <= 1
27-
? null
28-
: string.Join(Plugin.Query.TermSeparator, query.Terms.Skip(1)).ToLower();
26+
var termToSearch = query.Search;
2927

3028
var processlist = processHelper.GetMatchingProcesses(termToSearch);
3129

0 commit comments

Comments
 (0)