@@ -176,7 +176,8 @@ private void RegisterResultsUpdatedEvent()
176
176
var token = e . Token == default ? _updateToken : e . Token ;
177
177
178
178
PluginManager . UpdatePluginMetadata ( e . Results , pair . Metadata , e . Query ) ;
179
- if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( e . Results , pair . Metadata , e . Query , token ) ) )
179
+ if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( e . Results , pair . Metadata , e . Query ,
180
+ token ) ) )
180
181
{
181
182
Log . Error ( "MainViewModel" , "Unable to add item to Result Update Queue" ) ;
182
183
}
@@ -190,7 +191,8 @@ private async Task ReloadPluginDataAsync()
190
191
Hide ( ) ;
191
192
192
193
await PluginManager . ReloadDataAsync ( ) . ConfigureAwait ( false ) ;
193
- Notification . Show ( InternationalizationManager . Instance . GetTranslation ( "success" ) , InternationalizationManager . Instance . GetTranslation ( "completedSuccessfully" ) ) ;
194
+ Notification . Show ( InternationalizationManager . Instance . GetTranslation ( "success" ) ,
195
+ InternationalizationManager . Instance . GetTranslation ( "completedSuccessfully" ) ) ;
194
196
}
195
197
196
198
[ RelayCommand ]
@@ -265,6 +267,7 @@ private void AutocompleteQuery()
265
267
{
266
268
autoCompleteText = $ "{ result . ActionKeywordAssigned } { defaultSuggestion } ";
267
269
}
270
+
268
271
autoCompleteText = SelectedResults . SelectedItem . QuerySuggestionText ;
269
272
}
270
273
@@ -286,11 +289,13 @@ private async Task OpenResultAsync(string index)
286
289
{
287
290
results . SelectedIndex = int . Parse ( index ) ;
288
291
}
292
+
289
293
var result = results . SelectedItem ? . Result ;
290
294
if ( result == null )
291
295
{
292
296
return ;
293
297
}
298
+
294
299
var hideWindow = await result . ExecuteAsync ( new ActionContext
295
300
{
296
301
// not null means pressing modifier key + number, should ignore the modifier key
@@ -403,6 +408,7 @@ private async Task RegisterClockAndDateUpdateAsync()
403
408
public bool GameModeStatus { get ; set ; } = false ;
404
409
405
410
private string _queryText ;
411
+
406
412
public string QueryText
407
413
{
408
414
get => _queryText ;
@@ -426,6 +432,7 @@ private void IncreaseWidth()
426
432
Settings . WindowSize += 100 ;
427
433
Settings . WindowLeft -= 50 ;
428
434
}
435
+
429
436
OnPropertyChanged ( ) ;
430
437
}
431
438
@@ -441,6 +448,7 @@ private void DecreaseWidth()
441
448
Settings . WindowLeft += 50 ;
442
449
Settings . WindowSize -= 100 ;
443
450
}
451
+
444
452
OnPropertyChanged ( ) ;
445
453
}
446
454
@@ -520,18 +528,17 @@ public void ChangeQueryText(string queryText, bool isReQuery = false)
520
528
{
521
529
if ( QueryText != queryText )
522
530
{
523
-
524
531
// re-query is done in QueryText's setter method
525
532
QueryText = queryText ;
526
533
// set to false so the subsequent set true triggers
527
534
// PropertyChanged and MoveQueryTextToEnd is called
528
535
QueryTextCursorMovedToEnd = false ;
529
-
530
536
}
531
537
else if ( isReQuery )
532
538
{
533
539
Query ( isReQuery : true ) ;
534
540
}
541
+
535
542
QueryTextCursorMovedToEnd = true ;
536
543
} ) ;
537
544
}
@@ -601,8 +608,8 @@ public double MainWindowWidth
601
608
602
609
public string OpenResultCommandModifiers => Settings . OpenResultModifiers ;
603
610
604
- public string PreviewHotkey
605
- {
611
+ public string PreviewHotkey
612
+ {
606
613
get
607
614
{
608
615
// TODO try to patch issue #1755
@@ -616,6 +623,7 @@ public string PreviewHotkey
616
623
{
617
624
Settings . PreviewHotkey = "F1" ;
618
625
}
626
+
619
627
return Settings . PreviewHotkey ;
620
628
}
621
629
}
@@ -684,7 +692,6 @@ private void QueryContextMenu()
684
692
results . Add ( ContextMenuTopMost ( selected ) ) ;
685
693
results . Add ( ContextMenuPluginInfo ( selected . PluginID ) ) ;
686
694
}
687
-
688
695
689
696
690
697
if ( ! string . IsNullOrEmpty ( query ) )
@@ -703,7 +710,6 @@ private void QueryContextMenu()
703
710
704
711
r . Score = match . Score ;
705
712
return true ;
706
-
707
713
} ) . ToList ( ) ;
708
714
ContextMenu . AddResults ( filtered , id ) ;
709
715
}
@@ -730,10 +736,7 @@ private void QueryHistory()
730
736
Title = string . Format ( title , h . Query ) ,
731
737
SubTitle = string . Format ( time , h . ExecutedDateTime ) ,
732
738
IcoPath = "Images\\ history.png" ,
733
- OriginQuery = new Query
734
- {
735
- RawQuery = h . Query
736
- } ,
739
+ OriginQuery = new Query { RawQuery = h . Query } ,
737
740
Action = _ =>
738
741
{
739
742
SelectedResults = Results ;
@@ -870,20 +873,23 @@ async Task QueryTask(PluginPair plugin)
870
873
// Task.Yield will force it to run in ThreadPool
871
874
await Task . Yield ( ) ;
872
875
873
- IReadOnlyList < Result > results = await PluginManager . QueryForPluginAsync ( plugin , query , currentCancellationToken ) ;
876
+ IReadOnlyList < Result > results =
877
+ await PluginManager . QueryForPluginAsync ( plugin , query , currentCancellationToken ) ;
874
878
875
879
currentCancellationToken . ThrowIfCancellationRequested ( ) ;
876
880
877
881
results ??= _emptyResult ;
878
882
879
- if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( results , plugin . Metadata , query , currentCancellationToken ) ) )
883
+ if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( results , plugin . Metadata , query ,
884
+ currentCancellationToken ) ) )
880
885
{
881
886
Log . Error ( "MainViewModel" , "Unable to add item to Result Update Queue" ) ;
882
887
}
883
888
}
884
889
}
885
890
886
- private Query ConstructQuery ( string queryText , IEnumerable < CustomShortcutModel > customShortcuts , IEnumerable < BuiltinShortcutModel > builtInShortcuts )
891
+ private Query ConstructQuery ( string queryText , IEnumerable < CustomShortcutModel > customShortcuts ,
892
+ IEnumerable < BuiltinShortcutModel > builtInShortcuts )
887
893
{
888
894
if ( string . IsNullOrWhiteSpace ( queryText ) )
889
895
{
@@ -893,7 +899,7 @@ private Query ConstructQuery(string queryText, IEnumerable<CustomShortcutModel>
893
899
StringBuilder queryBuilder = new ( queryText ) ;
894
900
StringBuilder queryBuilderTmp = new ( queryText ) ;
895
901
896
- foreach ( var shortcut in customShortcuts )
902
+ foreach ( var shortcut in customShortcuts . OrderByDescending ( x => x . Key . Length ) )
897
903
{
898
904
if ( queryBuilder . Equals ( shortcut . Key ) )
899
905
{
@@ -920,7 +926,9 @@ private Query ConstructQuery(string queryText, IEnumerable<CustomShortcutModel>
920
926
}
921
927
catch ( Exception e )
922
928
{
923
- Log . Exception ( $ "{ nameof ( MainViewModel ) } .{ nameof ( ConstructQuery ) } |Error when expanding shortcut { shortcut . Key } ", e ) ;
929
+ Log . Exception (
930
+ $ "{ nameof ( MainViewModel ) } .{ nameof ( ConstructQuery ) } |Error when expanding shortcut { shortcut . Key } ",
931
+ e ) ;
924
932
}
925
933
}
926
934
} ) ;
@@ -1065,6 +1073,7 @@ public async void Hide()
1065
1073
{
1066
1074
SelectedResults = Results ;
1067
1075
}
1076
+
1068
1077
switch ( Settings . LastQueryMode )
1069
1078
{
1070
1079
case LastQueryMode . Empty :
0 commit comments