From 47ee718f8b7b6b5a3a053d0f0fb14512e12e35ab Mon Sep 17 00:00:00 2001 From: gissehel Date: Sun, 13 Mar 2022 16:59:07 +0100 Subject: [PATCH] Fix the caret position : Dispatch the caret move with a lower priority so the QueryTextBox has the new value when the code is executed --- Flow.Launcher/MainWindow.xaml.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 366407182..0573a948b 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -538,7 +538,9 @@ namespace Flow.Launcher private void MoveQueryTextToEnd() { - Dispatcher.Invoke(() => QueryTextBox.CaretIndex = QueryTextBox.Text.Length); + // QueryTextBox seems to be update with a DispatcherPriority as low as ContextIdle. + // To ensure QueryTextBox is up to date with QueryText from the View, we need to Dispatch with such a priority + Dispatcher.Invoke(() => QueryTextBox.CaretIndex = QueryTextBox.Text.Length, System.Windows.Threading.DispatcherPriority.ContextIdle); } public void InitializeColorScheme()