From f0bafd521d52c57103294faf0975812158dd1d38 Mon Sep 17 00:00:00 2001 From: stax76 Date: Thu, 10 Mar 2022 05:58:59 +0100 Subject: [PATCH 1/3] caret-position-fix --- Flow.Launcher/ViewModel/MainViewModel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 0fe3bdf8052..188199fbafe 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -346,6 +346,7 @@ public void ChangeQueryText(string queryText, bool reQuery = false) { // re-query is done in QueryText's setter method QueryText = queryText; + QueryTextCursorMovedToEnd = false; } else if (reQuery) { From 444f918914ffde9d8a3f087c6281f44948697a5f Mon Sep 17 00:00:00 2001 From: stax76 Date: Fri, 11 Mar 2022 13:57:54 +0100 Subject: [PATCH 2/3] code comment added for clarity --- Flow.Launcher/ViewModel/MainViewModel.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 188199fbafe..0531c925d78 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -346,6 +346,8 @@ public void ChangeQueryText(string queryText, bool reQuery = false) { // re-query is done in QueryText's setter method QueryText = queryText; + // set to false so the subsequent set true triggers + // PropertyChanged and MoveQueryTextToEnd is called QueryTextCursorMovedToEnd = false; } else if (reQuery) From 47ee718f8b7b6b5a3a053d0f0fb14512e12e35ab Mon Sep 17 00:00:00 2001 From: gissehel Date: Sun, 13 Mar 2022 16:59:07 +0100 Subject: [PATCH 3/3] 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 366407182e0..0573a948b05 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -538,7 +538,9 @@ private void OnKeyDown(object sender, KeyEventArgs e) 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()