Skip to content

Commit 29081ec

Browse files
committed
Wrap querytext change with Dispatcher to ensure it happens after mainwindow showup.
1 parent c5056a7 commit 29081ec

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ public MainViewModel(Settings settings)
6666
Settings = settings;
6767
Settings.PropertyChanged += (_, args) =>
6868
{
69-
switch (args.PropertyName) {
69+
switch (args.PropertyName)
70+
{
7071
case nameof(Settings.WindowSize):
7172
OnPropertyChanged(nameof(MainWindowWidth));
7273
break;
@@ -366,6 +367,7 @@ public string QueryText
366367
set
367368
{
368369
_queryText = value;
370+
OnPropertyChanged();
369371
Query();
370372
}
371373
}
@@ -429,11 +431,14 @@ public void ChangeQueryText(string queryText, bool reQuery = false)
429431
{
430432
if (QueryText != queryText)
431433
{
432-
// re-query is done in QueryText's setter method
433-
QueryText = queryText;
434-
// set to false so the subsequent set true triggers
435-
// PropertyChanged and MoveQueryTextToEnd is called
436-
QueryTextCursorMovedToEnd = false;
434+
Application.Current.Dispatcher.Invoke(() =>
435+
{
436+
// re-query is done in QueryText's setter method
437+
QueryText = queryText;
438+
// set to false so the subsequent set true triggers
439+
// PropertyChanged and MoveQueryTextToEnd is called
440+
QueryTextCursorMovedToEnd = false;
441+
});
437442
}
438443
else if (reQuery)
439444
{
@@ -752,7 +757,7 @@ private Query ConstructQuery(string queryText, IEnumerable<CustomShortcutModel>
752757

753758
queryBuilder.Replace('@' + shortcut.Key, shortcut.Expand());
754759
}
755-
760+
756761
Application.Current.Dispatcher.Invoke(() =>
757762
{
758763
foreach (var shortcut in builtInShortcuts)
@@ -887,9 +892,9 @@ public void Show()
887892
{
888893
MainWindowVisibility = Visibility.Visible;
889894

890-
MainWindowVisibilityStatus = true;
891-
892895
MainWindowOpacity = 1;
896+
897+
MainWindowVisibilityStatus = true;
893898
});
894899
}
895900

0 commit comments

Comments
 (0)