|
11 | 11 | using Microsoft.PowerShell.EditorServices.Logging; |
12 | 12 | using Microsoft.PowerShell.EditorServices.Services; |
13 | 13 | using Microsoft.PowerShell.EditorServices.Services.Configuration; |
| 14 | +using Microsoft.PowerShell.EditorServices.Services.Extension; |
| 15 | +using Microsoft.PowerShell.EditorServices.Services.PowerShell.Host; |
14 | 16 | using Newtonsoft.Json.Linq; |
15 | 17 | using OmniSharp.Extensions.LanguageServer.Protocol.Models; |
16 | 18 | using OmniSharp.Extensions.LanguageServer.Protocol.Server; |
17 | 19 | using OmniSharp.Extensions.LanguageServer.Protocol.Window; |
18 | 20 | using OmniSharp.Extensions.LanguageServer.Protocol.Workspace; |
19 | | -using Microsoft.PowerShell.EditorServices.Services.PowerShell.Host; |
20 | | -using Microsoft.PowerShell.EditorServices.Services.Extension; |
21 | 21 |
|
22 | 22 | namespace Microsoft.PowerShell.EditorServices.Handlers |
23 | 23 | { |
@@ -110,7 +110,6 @@ public override async Task<Unit> Handle(DidChangeConfigurationParams request, Ca |
110 | 110 | await _psesHost.SetInitialWorkingDirectoryAsync( |
111 | 111 | _configurationService.CurrentSettings.Cwd, |
112 | 112 | CancellationToken.None).ConfigureAwait(false); |
113 | | - |
114 | 113 | } |
115 | 114 | else if (_workspaceService.WorkspacePath is not null |
116 | 115 | && Directory.Exists(_workspaceService.WorkspacePath)) |
@@ -139,24 +138,35 @@ await _psesHost.SetInitialWorkingDirectoryAsync( |
139 | 138 |
|
140 | 139 | // Convert the editor file glob patterns into an array for the Workspace |
141 | 140 | // Both the files.exclude and search.exclude hash tables look like (glob-text, is-enabled): |
| 141 | + // |
142 | 142 | // "files.exclude" : { |
143 | 143 | // "Makefile": true, |
144 | 144 | // "*.html": true, |
| 145 | + // "**/*.js": { "when": "$(basename).ts" }, |
145 | 146 | // "build/*": true |
146 | 147 | // } |
| 148 | + // |
| 149 | + // TODO: We only support boolean values. The clause predicates are ignored, but perhaps |
| 150 | + // they shouldn't be. At least it doesn't crash! |
147 | 151 | List<string> excludeFilePatterns = new(); |
148 | 152 | if (incomingSettings.Files?.Exclude is not null) |
149 | 153 | { |
150 | | - foreach (KeyValuePair<string, bool> patternEntry in incomingSettings.Files.Exclude) |
| 154 | + foreach (KeyValuePair<string, object> patternEntry in incomingSettings.Files.Exclude) |
151 | 155 | { |
152 | | - if (patternEntry.Value) { excludeFilePatterns.Add(patternEntry.Key); } |
| 156 | + if (patternEntry.Value is bool v && v) |
| 157 | + { |
| 158 | + excludeFilePatterns.Add(patternEntry.Key); |
| 159 | + } |
153 | 160 | } |
154 | 161 | } |
155 | 162 | if (incomingSettings.Search?.Exclude is not null) |
156 | 163 | { |
157 | | - foreach (KeyValuePair<string, bool> patternEntry in incomingSettings.Search.Exclude) |
| 164 | + foreach (KeyValuePair<string, object> patternEntry in incomingSettings.Search.Exclude) |
158 | 165 | { |
159 | | - if (patternEntry.Value && !excludeFilePatterns.Contains(patternEntry.Key)) { excludeFilePatterns.Add(patternEntry.Key); } |
| 166 | + if (patternEntry.Value is bool v && v && !excludeFilePatterns.Contains(patternEntry.Key)) |
| 167 | + { |
| 168 | + excludeFilePatterns.Add(patternEntry.Key); |
| 169 | + } |
160 | 170 | } |
161 | 171 | } |
162 | 172 | _workspaceService.ExcludeFilesGlob = excludeFilePatterns; |
|
0 commit comments