From 3282f8531a4de4b94b23d85c51f90cfb6ffdb5ef Mon Sep 17 00:00:00 2001 From: Garulf <535299+Garulf@users.noreply.github.com> Date: Sun, 5 Dec 2021 14:13:53 -0500 Subject: [PATCH] Add checks after suggestion is calculated --- Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs index e7d560f83..08ee8571e 100644 --- a/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs +++ b/Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs @@ -42,7 +42,7 @@ namespace Flow.Launcher.Converters var selectedResultActionKeyword = string.IsNullOrEmpty(selectedResult.ActionKeywordAssigned) ? "" : selectedResult.ActionKeywordAssigned + " "; var selectedResultPossibleSuggestion = selectedResultActionKeyword + selectedResult.Title; - if (!selectedResultPossibleSuggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase) || QueryTextBox.HorizontalOffset != 0) + if (!selectedResultPossibleSuggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase)) return string.Empty; @@ -50,9 +50,10 @@ namespace Flow.Launcher.Converters // When user typed lower case and result title is uppercase, we still want to display suggestion selectedItem.QuerySuggestionText = queryText + selectedResultPossibleSuggestion.Substring(queryText.Length); + // Check if Text will be larger then our QueryTextBox System.Windows.Media.Typeface typeface = new Typeface(QueryTextBox.FontFamily, QueryTextBox.FontStyle, QueryTextBox.FontWeight, QueryTextBox.FontStretch); System.Windows.Media.FormattedText ft = new FormattedText(QueryTextBox.Text, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, QueryTextBox.FontSize, Brushes.Black); - if (ft.Width > QueryTextBox.ActualWidth) + if (ft.Width > QueryTextBox.ActualWidth || QueryTextBox.HorizontalOffset != 0) { return string.Empty; };