Skip to content

Commit 293ef48

Browse files
taoocerosjjw24
authored andcommitted
Merge pull request #1080 from gissehel/caret-position-fix
Caret position fix : Include PR #1074
1 parent 5e0aa19 commit 293ef48

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
@@ -504,7 +504,9 @@ private void OnKeyDown(object sender, KeyEventArgs e)
504504

505505
private void MoveQueryTextToEnd()
506506
{
507-
Dispatcher.Invoke(() => QueryTextBox.CaretIndex = QueryTextBox.Text.Length);
507+
// QueryTextBox seems to be update with a DispatcherPriority as low as ContextIdle.
508+
// To ensure QueryTextBox is up to date with QueryText from the View, we need to Dispatch with such a priority
509+
Dispatcher.Invoke(() => QueryTextBox.CaretIndex = QueryTextBox.Text.Length, System.Windows.Threading.DispatcherPriority.ContextIdle);
508510
}
509511

510512
public void InitializeColorScheme()

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,9 @@ public void ChangeQueryText(string queryText, bool reQuery = false)
332332
{
333333
// re-query is done in QueryText's setter method
334334
QueryText = queryText;
335+
// set to false so the subsequent set true triggers
336+
// PropertyChanged and MoveQueryTextToEnd is called
337+
QueryTextCursorMovedToEnd = false;
335338
}
336339
else if (reQuery)
337340
{

0 commit comments

Comments
 (0)