Skip to content

Commit 51a8916

Browse files
authored
Merge pull request #1080 from gissehel/caret-position-fix
Caret position fix : Include PR #1074
2 parents 3bc5bcb + 47ee718 commit 51a8916

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,9 @@ private void OnKeyDown(object sender, KeyEventArgs e)
538538

539539
private void MoveQueryTextToEnd()
540540
{
541-
Dispatcher.Invoke(() => QueryTextBox.CaretIndex = QueryTextBox.Text.Length);
541+
// QueryTextBox seems to be update with a DispatcherPriority as low as ContextIdle.
542+
// To ensure QueryTextBox is up to date with QueryText from the View, we need to Dispatch with such a priority
543+
Dispatcher.Invoke(() => QueryTextBox.CaretIndex = QueryTextBox.Text.Length, System.Windows.Threading.DispatcherPriority.ContextIdle);
542544
}
543545

544546
public void InitializeColorScheme()

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ public void ChangeQueryText(string queryText, bool reQuery = false)
346346
{
347347
// re-query is done in QueryText's setter method
348348
QueryText = queryText;
349+
// set to false so the subsequent set true triggers
350+
// PropertyChanged and MoveQueryTextToEnd is called
351+
QueryTextCursorMovedToEnd = false;
349352
}
350353
else if (reQuery)
351354
{

0 commit comments

Comments
 (0)