|
2 | 2 | // Licensed under the MIT License. See the LICENSE file in the project root for details. |
3 | 3 | using Microsoft.CommandPalette.Extensions; |
4 | 4 | using Microsoft.CommandPalette.Extensions.Toolkit; |
| 5 | +using WorkspaceLauncherForVSCode; |
5 | 6 | using WorkspaceLauncherForVSCode.Classes; |
6 | 7 | using WorkspaceLauncherForVSCode.Enums; |
7 | 8 |
|
8 | 9 | namespace Microsoft.CmdPal.Ext.Indexer.Indexer; |
9 | 10 |
|
10 | 11 | internal sealed partial class SearchFilters : Filters |
11 | 12 | { |
12 | | - public SearchFilters() |
| 13 | + private readonly SettingsManager _settingsManager; |
| 14 | + |
| 15 | + public SearchFilters(SettingsManager settingsManager) |
13 | 16 | { |
| 17 | + _settingsManager = settingsManager; |
14 | 18 | CurrentFilterId = nameof(FilterType.All); |
| 19 | + PropChanged += SearchFilters_PropChanged; |
| 20 | + } |
| 21 | + |
| 22 | + private void SearchFilters_PropChanged(object sender, IPropChangedEventArgs args) |
| 23 | + { |
| 24 | + var filterId = CurrentFilterId; |
| 25 | + var editions = _settingsManager.EnabledEditions; |
| 26 | + |
| 27 | + if (filterId == nameof(FilterType.VisualStudio) || filterId == nameof(FilterType.VisualStudio2026)) |
| 28 | + { |
| 29 | + if (!_settingsManager.EnableVisualStudio) |
| 30 | + { |
| 31 | + new ToastStatusMessage("Visual Studio is disabled in settings").Show(); |
| 32 | + } |
| 33 | + } |
| 34 | + else if (filterId == nameof(FilterType.Vscode)) |
| 35 | + { |
| 36 | + if (!editions.HasFlag(VisualStudioCodeEdition.Default) && |
| 37 | + !editions.HasFlag(VisualStudioCodeEdition.System) && |
| 38 | + !editions.HasFlag(VisualStudioCodeEdition.Custom) && |
| 39 | + !editions.HasFlag(VisualStudioCodeEdition.CustomPath)) |
| 40 | + { |
| 41 | + new ToastStatusMessage("Visual Studio Code is disabled in settings").Show(); |
| 42 | + } |
| 43 | + } |
| 44 | + else if (filterId == nameof(FilterType.VscodeInsider)) |
| 45 | + { |
| 46 | + if (!editions.HasFlag(VisualStudioCodeEdition.Insider)) |
| 47 | + { |
| 48 | + new ToastStatusMessage("Visual Studio Code Insiders is disabled in settings").Show(); |
| 49 | + } |
| 50 | + } |
| 51 | + else if (filterId == nameof(FilterType.Cursor)) |
| 52 | + { |
| 53 | + if (!editions.HasFlag(VisualStudioCodeEdition.Cursor)) |
| 54 | + { |
| 55 | + new ToastStatusMessage("Cursor is disabled in settings").Show(); |
| 56 | + } |
| 57 | + } |
| 58 | + else if (filterId == nameof(FilterType.Antigravity)) |
| 59 | + { |
| 60 | + if (!editions.HasFlag(VisualStudioCodeEdition.Antigravity)) |
| 61 | + { |
| 62 | + new ToastStatusMessage("Antigravity is disabled in settings").Show(); |
| 63 | + } |
| 64 | + } |
| 65 | + else if (filterId == nameof(FilterType.Windsurf)) |
| 66 | + { |
| 67 | + if (!editions.HasFlag(VisualStudioCodeEdition.Windsurf)) |
| 68 | + { |
| 69 | + new ToastStatusMessage("Windsurf is disabled in settings").Show(); |
| 70 | + } |
| 71 | + } |
| 72 | + else if (filterId == nameof(FilterType.Folder) || |
| 73 | + filterId == nameof(FilterType.Workspace) || |
| 74 | + filterId == nameof(FilterType.RemoteWsl) || |
| 75 | + filterId == nameof(FilterType.RemoteDevContainer) || |
| 76 | + filterId == nameof(FilterType.RemoteCodespaces) || |
| 77 | + filterId == nameof(FilterType.RemoteAttachedContainer) || |
| 78 | + filterId == nameof(FilterType.RemoteSSHRemote)) |
| 79 | + { |
| 80 | + if (editions == VisualStudioCodeEdition.None) |
| 81 | + { |
| 82 | + new ToastStatusMessage("Visual Studio Code and AI Editors are disabled in settings").Show(); |
| 83 | + } |
| 84 | + } |
15 | 85 | } |
16 | 86 |
|
17 | 87 | public override IFilterItem[] GetFilters() |
|
0 commit comments