@@ -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
@@ -414,6 +419,7 @@ private async Task RegisterClockAndDateUpdateAsync()
414
419
public bool GameModeStatus { get ; set ; } = false ;
415
420
416
421
private string _queryText ;
422
+
417
423
public string QueryText
418
424
{
419
425
get => _queryText ;
@@ -437,6 +443,7 @@ private void IncreaseWidth()
437
443
Settings . WindowSize += 100 ;
438
444
Settings . WindowLeft -= 50 ;
439
445
}
446
+
440
447
OnPropertyChanged ( ) ;
441
448
}
442
449
@@ -452,6 +459,7 @@ private void DecreaseWidth()
452
459
Settings . WindowLeft += 50 ;
453
460
Settings . WindowSize -= 100 ;
454
461
}
462
+
455
463
OnPropertyChanged ( ) ;
456
464
}
457
465
@@ -531,18 +539,17 @@ public void ChangeQueryText(string queryText, bool isReQuery = false)
531
539
{
532
540
if ( QueryText != queryText )
533
541
{
534
-
535
542
// re-query is done in QueryText's setter method
536
543
QueryText = queryText ;
537
544
// set to false so the subsequent set true triggers
538
545
// PropertyChanged and MoveQueryTextToEnd is called
539
546
QueryTextCursorMovedToEnd = false ;
540
-
541
547
}
542
548
else if ( isReQuery )
543
549
{
544
550
Query ( isReQuery : true ) ;
545
551
}
552
+
546
553
QueryTextCursorMovedToEnd = true ;
547
554
} ) ;
548
555
}
@@ -612,8 +619,8 @@ public double MainWindowWidth
612
619
613
620
public string OpenResultCommandModifiers => Settings . OpenResultModifiers ;
614
621
615
- public string PreviewHotkey
616
- {
622
+ public string PreviewHotkey
623
+ {
617
624
get
618
625
{
619
626
// TODO try to patch issue #1755
@@ -627,6 +634,7 @@ public string PreviewHotkey
627
634
{
628
635
Settings . PreviewHotkey = "F1" ;
629
636
}
637
+
630
638
return Settings . PreviewHotkey ;
631
639
}
632
640
}
@@ -695,7 +703,6 @@ private void QueryContextMenu()
695
703
results . Add ( ContextMenuTopMost ( selected ) ) ;
696
704
results . Add ( ContextMenuPluginInfo ( selected . PluginID ) ) ;
697
705
}
698
-
699
706
700
707
701
708
if ( ! string . IsNullOrEmpty ( query ) )
@@ -714,7 +721,6 @@ private void QueryContextMenu()
714
721
715
722
r . Score = match . Score ;
716
723
return true ;
717
-
718
724
} ) . ToList ( ) ;
719
725
ContextMenu . AddResults ( filtered , id ) ;
720
726
}
@@ -741,10 +747,7 @@ private void QueryHistory()
741
747
Title = string . Format ( title , h . Query ) ,
742
748
SubTitle = string . Format ( time , h . ExecutedDateTime ) ,
743
749
IcoPath = "Images\\ history.png" ,
744
- OriginQuery = new Query
745
- {
746
- RawQuery = h . Query
747
- } ,
750
+ OriginQuery = new Query { RawQuery = h . Query } ,
748
751
Action = _ =>
749
752
{
750
753
SelectedResults = Results ;
@@ -881,20 +884,23 @@ async Task QueryTask(PluginPair plugin)
881
884
// Task.Yield will force it to run in ThreadPool
882
885
await Task . Yield ( ) ;
883
886
884
- IReadOnlyList < Result > results = await PluginManager . QueryForPluginAsync ( plugin , query , currentCancellationToken ) ;
887
+ IReadOnlyList < Result > results =
888
+ await PluginManager . QueryForPluginAsync ( plugin , query , currentCancellationToken ) ;
885
889
886
890
currentCancellationToken . ThrowIfCancellationRequested ( ) ;
887
891
888
892
results ??= _emptyResult ;
889
893
890
- if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( results , plugin . Metadata , query , currentCancellationToken ) ) )
894
+ if ( ! _resultsUpdateChannelWriter . TryWrite ( new ResultsForUpdate ( results , plugin . Metadata , query ,
895
+ currentCancellationToken ) ) )
891
896
{
892
897
Log . Error ( "MainViewModel" , "Unable to add item to Result Update Queue" ) ;
893
898
}
894
899
}
895
900
}
896
901
897
- private Query ConstructQuery ( string queryText , IEnumerable < CustomShortcutModel > customShortcuts , IEnumerable < BuiltinShortcutModel > builtInShortcuts )
902
+ private Query ConstructQuery ( string queryText , IEnumerable < CustomShortcutModel > customShortcuts ,
903
+ IEnumerable < BuiltinShortcutModel > builtInShortcuts )
898
904
{
899
905
if ( string . IsNullOrWhiteSpace ( queryText ) )
900
906
{
@@ -904,7 +910,8 @@ private Query ConstructQuery(string queryText, IEnumerable<CustomShortcutModel>
904
910
StringBuilder queryBuilder = new ( queryText ) ;
905
911
StringBuilder queryBuilderTmp = new ( queryText ) ;
906
912
907
- foreach ( var shortcut in customShortcuts )
913
+ // Sorting order is important here, the reason is for matching longest shortcut by default
914
+ foreach ( var shortcut in customShortcuts . OrderByDescending ( x => x . Key . Length ) )
908
915
{
909
916
if ( queryBuilder . Equals ( shortcut . Key ) )
910
917
{
@@ -931,7 +938,9 @@ private Query ConstructQuery(string queryText, IEnumerable<CustomShortcutModel>
931
938
}
932
939
catch ( Exception e )
933
940
{
934
- Log . Exception ( $ "{ nameof ( MainViewModel ) } .{ nameof ( ConstructQuery ) } |Error when expanding shortcut { shortcut . Key } ", e ) ;
941
+ Log . Exception (
942
+ $ "{ nameof ( MainViewModel ) } .{ nameof ( ConstructQuery ) } |Error when expanding shortcut { shortcut . Key } ",
943
+ e ) ;
935
944
}
936
945
}
937
946
} ) ;
@@ -1076,6 +1085,7 @@ public async void Hide()
1076
1085
{
1077
1086
SelectedResults = Results ;
1078
1087
}
1088
+
1079
1089
switch ( Settings . LastQueryMode )
1080
1090
{
1081
1091
case LastQueryMode . Empty :
0 commit comments