diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs
index a459e9ee663..2c9b8d4fdbc 100644
--- a/Flow.Launcher.Plugin/Result.cs
+++ b/Flow.Launcher.Plugin/Result.cs
@@ -57,7 +57,10 @@ public string CopyText
/// for user on the plugin result. If autocomplete action for example is tab, pressing tab will have
/// the default constructed autocomplete text (result's Title), or the text provided here if not empty.
///
- /// When a value is not set, the will be used.
+ ///
+ /// When a value is not set, the will be used.
+ /// Please include the action keyword prefix when necessary because Flow does not prepend it automatically.
+ ///
public string AutoCompleteText { get; set; }
///
@@ -257,6 +260,17 @@ public string PluginDirectory
///
public bool ShowBadge { get; set; } = false;
+ ///
+ /// This holds the text which can be shown as a query suggestion.
+ ///
+ ///
+ /// When a value is not set, the will be used.
+ /// Do not include the action keyword prefix because Flow prepends it automatically.
+ /// If the it does not start with the query text, it will not be shown as a suggestion.
+ /// So make sure to set this value to start with the query text.
+ ///
+ public string QuerySuggestionText { get; set; }
+
///
/// Run this result, asynchronously
///
@@ -307,7 +321,8 @@ public Result Clone()
Preview = Preview,
AddSelectedCount = AddSelectedCount,
RecordKey = RecordKey,
- ShowBadge = ShowBadge
+ ShowBadge = ShowBadge,
+ QuerySuggestionText = QuerySuggestionText
};
}
diff --git a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
index eb492e3344e..c2d7d016ca4 100644
--- a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
+++ b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
@@ -33,15 +33,39 @@ values[2] is not string queryText ||
{
var selectedResult = selectedItem.Result;
var selectedResultActionKeyword = string.IsNullOrEmpty(selectedResult.ActionKeywordAssigned) ? "" : selectedResult.ActionKeywordAssigned + " ";
- var selectedResultPossibleSuggestion = selectedResultActionKeyword + selectedResult.Title;
- if (!selectedResultPossibleSuggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
- return string.Empty;
+ string selectedResultPossibleSuggestion = null;
+
+ // Firstly check if the result has QuerySuggestionText
+ if (!string.IsNullOrEmpty(selectedResult.QuerySuggestionText))
+ {
+ selectedResultPossibleSuggestion = selectedResultActionKeyword + selectedResult.QuerySuggestionText;
+
+ // If this QuerySuggestionText does not start with the queryText, set it to null
+ if (!selectedResultPossibleSuggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
+ {
+ selectedResultPossibleSuggestion = null;
+ }
+ }
+
+ // Then check Title as suggestion
+ if (string.IsNullOrEmpty(selectedResultPossibleSuggestion))
+ {
+ selectedResultPossibleSuggestion = selectedResultActionKeyword + selectedResult.Title;
+ // If this QuerySuggestionText does not start with the queryText, set it to null
+ if (!selectedResultPossibleSuggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
+ {
+ selectedResultPossibleSuggestion = null;
+ }
+ }
+
+ if (string.IsNullOrEmpty(selectedResultPossibleSuggestion))
+ return string.Empty;
// For AutocompleteQueryCommand.
// When user typed lower case and result title is uppercase, we still want to display suggestion
- selectedItem.QuerySuggestionText = queryText + selectedResultPossibleSuggestion.Substring(queryText.Length);
+ selectedItem.QuerySuggestionText = string.Concat(queryText, selectedResultPossibleSuggestion.AsSpan(queryText.Length));
// Check if Text will be larger than our QueryTextBox
Typeface typeface = new Typeface(queryTextBox.FontFamily, queryTextBox.FontStyle, queryTextBox.FontWeight, queryTextBox.FontStretch);