@@ -33,15 +33,39 @@ values[2] is not string queryText ||
33
33
{
34
34
var selectedResult = selectedItem . Result ;
35
35
var selectedResultActionKeyword = string . IsNullOrEmpty ( selectedResult . ActionKeywordAssigned ) ? "" : selectedResult . ActionKeywordAssigned + " " ;
36
- var selectedResultPossibleSuggestion = selectedResultActionKeyword + selectedResult . Title ;
37
36
38
- if ( ! selectedResultPossibleSuggestion . StartsWith ( queryText , StringComparison . CurrentCultureIgnoreCase ) )
39
- return string . Empty ;
37
+ string selectedResultPossibleSuggestion = null ;
38
+
39
+ // Firstly check if the result has QuerySuggestionText
40
+ if ( ! string . IsNullOrEmpty ( selectedResult . QuerySuggestionText ) )
41
+ {
42
+ selectedResultPossibleSuggestion = selectedResultActionKeyword + selectedResult . QuerySuggestionText ;
43
+
44
+ // If this QuerySuggestionText does not start with the queryText, set it to null
45
+ if ( ! selectedResultPossibleSuggestion . StartsWith ( queryText , StringComparison . CurrentCultureIgnoreCase ) )
46
+ {
47
+ selectedResultPossibleSuggestion = null ;
48
+ }
49
+ }
50
+
51
+ // Then check Title as suggestion
52
+ if ( string . IsNullOrEmpty ( selectedResultPossibleSuggestion ) )
53
+ {
54
+ selectedResultPossibleSuggestion = selectedResultActionKeyword + selectedResult . Title ;
40
55
56
+ // If this QuerySuggestionText does not start with the queryText, set it to null
57
+ if ( ! selectedResultPossibleSuggestion . StartsWith ( queryText , StringComparison . CurrentCultureIgnoreCase ) )
58
+ {
59
+ selectedResultPossibleSuggestion = null ;
60
+ }
61
+ }
62
+
63
+ if ( string . IsNullOrEmpty ( selectedResultPossibleSuggestion ) )
64
+ return string . Empty ;
41
65
42
66
// For AutocompleteQueryCommand.
43
67
// When user typed lower case and result title is uppercase, we still want to display suggestion
44
- selectedItem . QuerySuggestionText = queryText + selectedResultPossibleSuggestion . Substring ( queryText . Length ) ;
68
+ selectedItem . QuerySuggestionText = string . Concat ( queryText , selectedResultPossibleSuggestion . AsSpan ( queryText . Length ) ) ;
45
69
46
70
// Check if Text will be larger than our QueryTextBox
47
71
Typeface typeface = new Typeface ( queryTextBox . FontFamily , queryTextBox . FontStyle , queryTextBox . FontWeight , queryTextBox . FontStretch ) ;
0 commit comments