|
4 | 4 | using CommunityToolkit.WinUI; |
5 | 5 | using Files.App.Controls; |
6 | 6 | using Files.Shared.Helpers; |
| 7 | +using Microsoft.Extensions.Logging; |
7 | 8 | using Microsoft.UI.Dispatching; |
8 | 9 | using Microsoft.UI.Xaml; |
9 | 10 | using Microsoft.UI.Xaml.Controls; |
@@ -264,7 +265,33 @@ public bool IsOmnibarFocused |
264 | 265 | } |
265 | 266 |
|
266 | 267 | private string _OmnibarCurrentSelectedModeName = OmnibarPathModeName; |
267 | | - public string OmnibarCurrentSelectedModeName { get => _OmnibarCurrentSelectedModeName; set => SetProperty(ref _OmnibarCurrentSelectedModeName, value); } |
| 268 | + public string OmnibarCurrentSelectedModeName |
| 269 | + { |
| 270 | + get => _OmnibarCurrentSelectedModeName; |
| 271 | + set |
| 272 | + { |
| 273 | + if (SetProperty(ref _OmnibarCurrentSelectedModeName, value) && IsOmnibarFocused) |
| 274 | + { |
| 275 | + switch (value) |
| 276 | + { |
| 277 | + case OmnibarPathModeName: |
| 278 | + PathText = |
| 279 | + string.IsNullOrEmpty(ContentPageContext.ShellPage?.ShellViewModel?.WorkingDirectory) |
| 280 | + ? Constants.UserEnvironmentPaths.HomePath |
| 281 | + : ContentPageContext.ShellPage.ShellViewModel.WorkingDirectory; |
| 282 | + _ = PopulateOmnibarSuggestionsForPathMode(); |
| 283 | + break; |
| 284 | + case OmnibarPaletteModeName: |
| 285 | + PopulateOmnibarSuggestionsForCommandPaletteMode(); |
| 286 | + break; |
| 287 | + case OmnibarSearchModeName: |
| 288 | + break; |
| 289 | + default: |
| 290 | + break; |
| 291 | + } |
| 292 | + } |
| 293 | + } |
| 294 | + } |
268 | 295 |
|
269 | 296 | private CurrentInstanceViewModel _InstanceViewModel; |
270 | 297 | public CurrentInstanceViewModel InstanceViewModel |
@@ -735,7 +762,6 @@ await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidItemDialogTitle.GetLoca |
735 | 762 | } |
736 | 763 |
|
737 | 764 | PathControlDisplayText = ContentPageContext.ShellPage.ShellViewModel.WorkingDirectory; |
738 | | - IsOmnibarFocused = false; |
739 | 765 | } |
740 | 766 |
|
741 | 767 | public void PathBoxItem_PreviewKeyDown(object sender, KeyRoutedEventArgs e) |
@@ -1074,6 +1100,8 @@ private static async Task<bool> LaunchApplicationFromPath(string currentInput, s |
1074 | 1100 |
|
1075 | 1101 | public async Task PopulateOmnibarSuggestionsForPathMode() |
1076 | 1102 | { |
| 1103 | + PathModeSuggestionItems.Clear(); |
| 1104 | + |
1077 | 1105 | var result = await SafetyExtensions.IgnoreExceptions((Func<Task<bool>>)(async () => |
1078 | 1106 | { |
1079 | 1107 | List<OmnibarPathModeSuggestionModel>? newSuggestions = []; |
@@ -1114,9 +1142,7 @@ public async Task PopulateOmnibarSuggestionsForPathMode() |
1114 | 1142 |
|
1115 | 1143 | // If there are no suggestions, show "No suggestions" |
1116 | 1144 | if (newSuggestions.Count is 0) |
1117 | | - { |
1118 | | - AddNoResultsItem(); |
1119 | | - } |
| 1145 | + return false; |
1120 | 1146 |
|
1121 | 1147 | // Check whether at least one item is in common between the old and the new suggestions |
1122 | 1148 | // since the suggestions popup becoming empty causes flickering |
|
0 commit comments