@@ -177,7 +177,8 @@ private void RegisterResultsUpdatedEvent()
177
177
var token = e . Token == default ? _updateToken : e . Token ;
178
178
179
179
PluginManager . UpdatePluginMetadata ( e . Results , pair . Metadata , e . Query ) ;
180
- if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( e . Results , pair . Metadata , e . Query , token ) ) )
180
+ if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( e . Results , pair . Metadata , e . Query ,
181
+ token ) ) )
181
182
{
182
183
Log . Error ( "MainViewModel" , "Unable to add item to Result Update Queue" ) ;
183
184
}
@@ -191,7 +192,8 @@ private async Task ReloadPluginDataAsync()
191
192
Hide ( ) ;
192
193
193
194
await PluginManager . ReloadDataAsync ( ) . ConfigureAwait ( false ) ;
194
- Notification . Show ( InternationalizationManager . Instance . GetTranslation ( "success" ) , InternationalizationManager . Instance . GetTranslation ( "completedSuccessfully" ) ) ;
195
+ Notification . Show ( InternationalizationManager . Instance . GetTranslation ( "success" ) ,
196
+ InternationalizationManager . Instance . GetTranslation ( "completedSuccessfully" ) ) ;
195
197
}
196
198
197
199
[ RelayCommand ]
@@ -221,8 +223,7 @@ public void ReQuery(bool reselect)
221
223
{
222
224
if ( SelectedIsFromQueryResults ( ) )
223
225
{
224
- _reselect = reselect ;
225
- QueryResults ( isReQuery : true ) ;
226
+ QueryResults ( isReQuery : true , reselect : reselect ) ;
226
227
}
227
228
}
228
229
@@ -275,6 +276,7 @@ private void AutocompleteQuery()
275
276
{
276
277
autoCompleteText = $ "{ result . ActionKeywordAssigned } { defaultSuggestion } ";
277
278
}
279
+
278
280
autoCompleteText = SelectedResults . SelectedItem . QuerySuggestionText ;
279
281
}
280
282
@@ -296,11 +298,13 @@ private async Task OpenResultAsync(string index)
296
298
{
297
299
results . SelectedIndex = int . Parse ( index ) ;
298
300
}
301
+
299
302
var result = results . SelectedItem ? . Result ;
300
303
if ( result == null )
301
304
{
302
305
return ;
303
306
}
307
+
304
308
var hideWindow = await result . ExecuteAsync ( new ActionContext
305
309
{
306
310
// not null means pressing modifier key + number, should ignore the modifier key
@@ -413,6 +417,7 @@ private async Task RegisterClockAndDateUpdateAsync()
413
417
public bool GameModeStatus { get ; set ; } = false ;
414
418
415
419
private string _queryText ;
420
+
416
421
public string QueryText
417
422
{
418
423
get => _queryText ;
@@ -436,6 +441,7 @@ private void IncreaseWidth()
436
441
Settings . WindowSize += 100 ;
437
442
Settings . WindowLeft -= 50 ;
438
443
}
444
+
439
445
OnPropertyChanged ( ) ;
440
446
}
441
447
@@ -451,6 +457,7 @@ private void DecreaseWidth()
451
457
Settings . WindowLeft += 50 ;
452
458
Settings . WindowSize -= 100 ;
453
459
}
460
+
454
461
OnPropertyChanged ( ) ;
455
462
}
456
463
@@ -530,18 +537,17 @@ public void ChangeQueryText(string queryText, bool isReQuery = false)
530
537
{
531
538
if ( QueryText != queryText )
532
539
{
533
-
534
540
// re-query is done in QueryText's setter method
535
541
QueryText = queryText ;
536
542
// set to false so the subsequent set true triggers
537
543
// PropertyChanged and MoveQueryTextToEnd is called
538
544
QueryTextCursorMovedToEnd = false ;
539
-
540
545
}
541
546
else if ( isReQuery )
542
547
{
543
548
Query ( isReQuery : true ) ;
544
549
}
550
+
545
551
QueryTextCursorMovedToEnd = true ;
546
552
} ) ;
547
553
}
@@ -611,8 +617,8 @@ public double MainWindowWidth
611
617
612
618
public string OpenResultCommandModifiers => Settings . OpenResultModifiers ;
613
619
614
- public string PreviewHotkey
615
- {
620
+ public string PreviewHotkey
621
+ {
616
622
get
617
623
{
618
624
// TODO try to patch issue #1755
@@ -626,6 +632,7 @@ public string PreviewHotkey
626
632
{
627
633
Settings . PreviewHotkey = "F1" ;
628
634
}
635
+
629
636
return Settings . PreviewHotkey ;
630
637
}
631
638
}
@@ -694,7 +701,6 @@ private void QueryContextMenu()
694
701
results . Add ( ContextMenuTopMost ( selected ) ) ;
695
702
results . Add ( ContextMenuPluginInfo ( selected . PluginID ) ) ;
696
703
}
697
-
698
704
699
705
700
706
if ( ! string . IsNullOrEmpty ( query ) )
@@ -713,7 +719,6 @@ private void QueryContextMenu()
713
719
714
720
r . Score = match . Score ;
715
721
return true ;
716
-
717
722
} ) . ToList ( ) ;
718
723
ContextMenu . AddResults ( filtered , id ) ;
719
724
}
@@ -740,10 +745,7 @@ private void QueryHistory()
740
745
Title = string . Format ( title , h . Query ) ,
741
746
SubTitle = string . Format ( time , h . ExecutedDateTime ) ,
742
747
IcoPath = "Images\\ history.png" ,
743
- OriginQuery = new Query
744
- {
745
- RawQuery = h . Query
746
- } ,
748
+ OriginQuery = new Query { RawQuery = h . Query } ,
747
749
Action = _ =>
748
750
{
749
751
SelectedResults = Results ;
@@ -771,7 +773,7 @@ private void QueryHistory()
771
773
772
774
private readonly IReadOnlyList < Result > _emptyResult = new List < Result > ( ) ;
773
775
774
- private async void QueryResults ( bool isReQuery = false )
776
+ private async void QueryResults ( bool isReQuery = false , bool reselect = true )
775
777
{
776
778
_updateSource ? . Cancel ( ) ;
777
779
@@ -880,20 +882,23 @@ async Task QueryTask(PluginPair plugin)
880
882
// Task.Yield will force it to run in ThreadPool
881
883
await Task . Yield ( ) ;
882
884
883
- IReadOnlyList < Result > results = await PluginManager . QueryForPluginAsync ( plugin , query , currentCancellationToken ) ;
885
+ IReadOnlyList < Result > results =
886
+ await PluginManager . QueryForPluginAsync ( plugin , query , currentCancellationToken ) ;
884
887
885
888
currentCancellationToken . ThrowIfCancellationRequested ( ) ;
886
889
887
890
results ??= _emptyResult ;
888
891
889
- if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( results , plugin . Metadata , query , currentCancellationToken ) ) )
892
+ if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( results , plugin . Metadata , query ,
893
+ currentCancellationToken , reselect ) ) )
890
894
{
891
895
Log . Error ( "MainViewModel" , "Unable to add item to Result Update Queue" ) ;
892
896
}
893
897
}
894
898
}
895
899
896
- private Query ConstructQuery ( string queryText , IEnumerable < CustomShortcutModel > customShortcuts , IEnumerable < BuiltinShortcutModel > builtInShortcuts )
900
+ private Query ConstructQuery ( string queryText , IEnumerable < CustomShortcutModel > customShortcuts ,
901
+ IEnumerable < BuiltinShortcutModel > builtInShortcuts )
897
902
{
898
903
if ( string . IsNullOrWhiteSpace ( queryText ) )
899
904
{
@@ -930,7 +935,9 @@ private Query ConstructQuery(string queryText, IEnumerable<CustomShortcutModel>
930
935
}
931
936
catch ( Exception e )
932
937
{
933
- Log . Exception ( $ "{ nameof ( MainViewModel ) } .{ nameof ( ConstructQuery ) } |Error when expanding shortcut { shortcut . Key } ", e ) ;
938
+ Log . Exception (
939
+ $ "{ nameof ( MainViewModel ) } .{ nameof ( ConstructQuery ) } |Error when expanding shortcut { shortcut . Key } ",
940
+ e ) ;
934
941
}
935
942
}
936
943
} ) ;
@@ -1075,6 +1082,7 @@ public async void Hide()
1075
1082
{
1076
1083
SelectedResults = Results ;
1077
1084
}
1085
+
1078
1086
switch ( Settings . LastQueryMode )
1079
1087
{
1080
1088
case LastQueryMode . Empty :
@@ -1122,7 +1130,7 @@ public void Save()
1122
1130
/// <summary>
1123
1131
/// To avoid deadlock, this method should not called from main thread
1124
1132
/// </summary>
1125
- public void UpdateResultView ( IEnumerable < ResultsForUpdate > resultsForUpdates )
1133
+ public void UpdateResultView ( ICollection < ResultsForUpdate > resultsForUpdates )
1126
1134
{
1127
1135
if ( ! resultsForUpdates . Any ( ) )
1128
1136
return ;
@@ -1161,7 +1169,10 @@ public void UpdateResultView(IEnumerable<ResultsForUpdate> resultsForUpdates)
1161
1169
}
1162
1170
}
1163
1171
1164
- Results . AddResults ( resultsForUpdates , token , _reselect ) ;
1172
+ // it should be the same for all results
1173
+ bool reSelect = resultsForUpdates . First ( ) . ReSelectFirstResult ;
1174
+
1175
+ Results . AddResults ( resultsForUpdates , token , reSelect ) ;
1165
1176
_reselect = true ;
1166
1177
}
1167
1178
0 commit comments