@@ -42,6 +42,7 @@ public partial class MainViewModel : BaseModel, ISavable
42
42
private readonly FlowLauncherJsonStorage < UserSelectedRecord > _userSelectedRecordStorage ;
43
43
private readonly FlowLauncherJsonStorage < TopMostRecord > _topMostRecordStorage ;
44
44
private readonly History _history ;
45
+ private int lasthistoryindex = 1 ;
45
46
private readonly UserSelectedRecord _userSelectedRecord ;
46
47
private readonly TopMostRecord _topMostRecord ;
47
48
@@ -83,6 +84,12 @@ public MainViewModel(Settings settings)
83
84
case nameof ( Settings . AutoCompleteHotkey ) :
84
85
OnPropertyChanged ( nameof ( AutoCompleteHotkey ) ) ;
85
86
break ;
87
+ case nameof ( Settings . CycleHistoryUpHotkey ) :
88
+ OnPropertyChanged ( nameof ( CycleHistoryUpHotkey ) ) ;
89
+ break ;
90
+ case nameof ( Settings . CycleHistoryDownHotkey ) :
91
+ OnPropertyChanged ( nameof ( CycleHistoryDownHotkey ) ) ;
92
+ break ;
86
93
case nameof ( Settings . AutoCompleteHotkey2 ) :
87
94
OnPropertyChanged ( nameof ( AutoCompleteHotkey2 ) ) ;
88
95
break ;
@@ -256,6 +263,49 @@ public void ReQuery(bool reselect)
256
263
}
257
264
}
258
265
266
+ [ RelayCommand ]
267
+ public void ReverseHistory ( )
268
+ {
269
+ if ( _history . Items . Count > 0 )
270
+ {
271
+ ChangeQueryText ( _history . Items [ _history . Items . Count - lasthistoryindex ] . Query . ToString ( ) ) ;
272
+ if ( lasthistoryindex < _history . Items . Count )
273
+ {
274
+ lasthistoryindex ++ ;
275
+ }
276
+ }
277
+ }
278
+
279
+ [ RelayCommand ]
280
+ public void ForwardHistory ( )
281
+ {
282
+ if ( _history . Items . Count > 0 )
283
+ {
284
+ ChangeQueryText ( _history . Items [ _history . Items . Count - lasthistoryindex ] . Query . ToString ( ) ) ;
285
+ if ( lasthistoryindex > 1 )
286
+ {
287
+ lasthistoryindex -- ;
288
+ }
289
+ }
290
+ }
291
+
292
+ [ RelayCommand ]
293
+ public void ReverseHistoryOnEmptyQuery ( )
294
+ {
295
+ var results = SelectedResults ;
296
+ if ( _history . Items . Count > 0
297
+ && _queryText == String . Empty
298
+ && ! HistorySelected ( )
299
+ && ! ContextMenuSelected ( ) )
300
+ {
301
+ ReverseHistory ( ) ;
302
+ }
303
+ else
304
+ {
305
+ SelectedResults . SelectPrevResult ( ) ;
306
+ }
307
+ }
308
+
259
309
[ RelayCommand ]
260
310
private void LoadContextMenu ( )
261
311
{
@@ -394,7 +444,20 @@ private void SelectNextPage()
394
444
[ RelayCommand ]
395
445
private void SelectPrevItem ( )
396
446
{
397
- SelectedResults . SelectPrevResult ( ) ;
447
+ var results = SelectedResults ;
448
+ if ( _history . Items . Count > 0
449
+ && _queryText == String . Empty
450
+ && ! HistorySelected ( )
451
+ && ! ContextMenuSelected ( ) )
452
+ {
453
+ lasthistoryindex = 1 ;
454
+ ReverseHistory ( ) ;
455
+ }
456
+ else
457
+ {
458
+ SelectedResults . SelectPrevResult ( ) ;
459
+ }
460
+
398
461
}
399
462
400
463
[ RelayCommand ]
@@ -690,6 +753,8 @@ public string VerifyOrSetDefaultHotkey(string hotkey, string defaultHotkey)
690
753
public string SelectPrevPageHotkey => VerifyOrSetDefaultHotkey ( Settings . SelectPrevPageHotkey , "" ) ;
691
754
public string OpenContextMenuHotkey => VerifyOrSetDefaultHotkey ( Settings . OpenContextMenuHotkey , "Ctrl+O" ) ;
692
755
public string SettingWindowHotkey => VerifyOrSetDefaultHotkey ( Settings . SettingWindowHotkey , "Ctrl+I" ) ;
756
+ public string CycleHistoryUpHotkey => VerifyOrSetDefaultHotkey ( Settings . CycleHistoryUpHotkey , "Alt+Up" ) ;
757
+ public string CycleHistoryDownHotkey => VerifyOrSetDefaultHotkey ( Settings . CycleHistoryDownHotkey , "Alt+Down" ) ;
693
758
694
759
695
760
public string Image => Constant . QueryTextBoxIconImagePath ;
@@ -1116,6 +1181,7 @@ public void Show()
1116
1181
1117
1182
public async void Hide ( )
1118
1183
{
1184
+ lasthistoryindex = 1 ;
1119
1185
// Trick for no delay
1120
1186
MainWindowOpacity = 0 ;
1121
1187
lastContextMenuResult = new Result ( ) ;
0 commit comments