public async Task <Unit> Handle(DidChangeConfigurationParams request, CancellationToken cancellationToken) { LanguageServerSettingsWrapper incomingSettings = request.Settings.ToObject <LanguageServerSettingsWrapper>(); if (incomingSettings == null) { return(await Unit.Task.ConfigureAwait(false)); } bool oldLoadProfiles = _configurationService.CurrentSettings.EnableProfileLoading; bool oldScriptAnalysisEnabled = _configurationService.CurrentSettings.ScriptAnalysis.Enable ?? false; string oldScriptAnalysisSettingsPath = _configurationService.CurrentSettings.ScriptAnalysis?.SettingsPath; _configurationService.CurrentSettings.Update( incomingSettings.Powershell, _workspaceService.WorkspacePath, _logger); if (!this._profilesLoaded && _configurationService.CurrentSettings.EnableProfileLoading && oldLoadProfiles != _configurationService.CurrentSettings.EnableProfileLoading) { await _powerShellContextService.LoadHostProfilesAsync().ConfigureAwait(false); this._profilesLoaded = true; } // Wait until after profiles are loaded (or not, if that's the // case) before starting the interactive console. if (!this._consoleReplStarted) { // Start the interactive terminal _powerShellContextService.ConsoleReader.StartCommandLoop(); this._consoleReplStarted = true; } // Run any events subscribed to configuration updates ConfigurationUpdated(this, _configurationService.CurrentSettings); // Convert the editor file glob patterns into an array for the Workspace // Both the files.exclude and search.exclude hash tables look like (glob-text, is-enabled): // "files.exclude" : { // "Makefile": true, // "*.html": true, // "build/*": true // } var excludeFilePatterns = new List <string>(); if (incomingSettings.Files?.Exclude != null) { foreach (KeyValuePair <string, bool> patternEntry in incomingSettings.Files.Exclude) { if (patternEntry.Value) { excludeFilePatterns.Add(patternEntry.Key); } } } if (incomingSettings.Search?.Exclude != null) { foreach (KeyValuePair <string, bool> patternEntry in incomingSettings.Search.Exclude) { if (patternEntry.Value && !excludeFilePatterns.Contains(patternEntry.Key)) { excludeFilePatterns.Add(patternEntry.Key); } } } _workspaceService.ExcludeFilesGlob = excludeFilePatterns; // Convert the editor file search options to Workspace properties if (incomingSettings.Search?.FollowSymlinks != null) { _workspaceService.FollowSymlinks = incomingSettings.Search.FollowSymlinks; } return(await Unit.Task.ConfigureAwait(false)); }
public override async Task <Unit> Handle(DidChangeConfigurationParams request, CancellationToken cancellationToken) { LanguageServerSettingsWrapper incomingSettings = request.Settings.ToObject <LanguageServerSettingsWrapper>(); if (incomingSettings == null) { return(await Unit.Task.ConfigureAwait(false)); } SendFeatureChangesTelemetry(incomingSettings); bool profileLoadingPreviouslyEnabled = _configurationService.CurrentSettings.EnableProfileLoading; bool oldScriptAnalysisEnabled = _configurationService.CurrentSettings.ScriptAnalysis.Enable ?? false; string oldScriptAnalysisSettingsPath = _configurationService.CurrentSettings.ScriptAnalysis?.SettingsPath; _configurationService.CurrentSettings.Update( incomingSettings.Powershell, _workspaceService.WorkspacePath, _logger); if (!this._cwdSet) { if (!string.IsNullOrEmpty(_configurationService.CurrentSettings.Cwd) && Directory.Exists(_configurationService.CurrentSettings.Cwd)) { await _powerShellContextService.SetWorkingDirectoryAsync( _configurationService.CurrentSettings.Cwd, isPathAlreadyEscaped : false).ConfigureAwait(false); } else if (_workspaceService.WorkspacePath != null && Directory.Exists(_workspaceService.WorkspacePath)) { await _powerShellContextService.SetWorkingDirectoryAsync( _workspaceService.WorkspacePath, isPathAlreadyEscaped : false).ConfigureAwait(false); } this._cwdSet = true; } // We need to load the profiles if: // - Profile loading is configured, AND // - Profiles haven't been loaded before, OR // - The profile loading configuration just changed if (_configurationService.CurrentSettings.EnableProfileLoading && (!this._profilesLoaded || !profileLoadingPreviouslyEnabled)) { await _powerShellContextService.LoadHostProfilesAsync().ConfigureAwait(false); this._profilesLoaded = true; } // Wait until after profiles are loaded (or not, if that's the // case) before starting the interactive console. if (!this._consoleReplStarted) { // Start the interactive terminal _powerShellContextService.ConsoleReader.StartCommandLoop(); this._consoleReplStarted = true; } // Run any events subscribed to configuration updates ConfigurationUpdated(this, _configurationService.CurrentSettings); // Convert the editor file glob patterns into an array for the Workspace // Both the files.exclude and search.exclude hash tables look like (glob-text, is-enabled): // "files.exclude" : { // "Makefile": true, // "*.html": true, // "build/*": true // } var excludeFilePatterns = new List <string>(); if (incomingSettings.Files?.Exclude != null) { foreach (KeyValuePair <string, bool> patternEntry in incomingSettings.Files.Exclude) { if (patternEntry.Value) { excludeFilePatterns.Add(patternEntry.Key); } } } if (incomingSettings.Search?.Exclude != null) { foreach (KeyValuePair <string, bool> patternEntry in incomingSettings.Search.Exclude) { if (patternEntry.Value && !excludeFilePatterns.Contains(patternEntry.Key)) { excludeFilePatterns.Add(patternEntry.Key); } } } _workspaceService.ExcludeFilesGlob = excludeFilePatterns; // Convert the editor file search options to Workspace properties if (incomingSettings.Search?.FollowSymlinks != null) { _workspaceService.FollowSymlinks = incomingSettings.Search.FollowSymlinks; } return(await Unit.Task.ConfigureAwait(false)); }
public async Task <Unit> Handle(DidChangeConfigurationParams request, CancellationToken cancellationToken) { LanguageServerSettingsWrapper incomingSettings = request.Settings.ToObject <LanguageServerSettingsWrapper>(); if (incomingSettings == null) { return(await Unit.Task.ConfigureAwait(false)); } bool oldLoadProfiles = _configurationService.CurrentSettings.EnableProfileLoading; bool oldScriptAnalysisEnabled = _configurationService.CurrentSettings.ScriptAnalysis.Enable ?? false; string oldScriptAnalysisSettingsPath = _configurationService.CurrentSettings.ScriptAnalysis?.SettingsPath; _configurationService.CurrentSettings.Update( incomingSettings.Powershell, _workspaceService.WorkspacePath, _logger); if (!this._profilesLoaded && _configurationService.CurrentSettings.EnableProfileLoading && oldLoadProfiles != _configurationService.CurrentSettings.EnableProfileLoading) { await _powerShellContextService.LoadHostProfilesAsync().ConfigureAwait(false); this._profilesLoaded = true; } // Wait until after profiles are loaded (or not, if that's the // case) before starting the interactive console. if (!this._consoleReplStarted) { // Start the interactive terminal _powerShellContextService.ConsoleReader.StartCommandLoop(); this._consoleReplStarted = true; } // If there is a new settings file path, restart the analyzer with the new settings. bool settingsPathChanged = false; string newSettingsPath = _configurationService.CurrentSettings.ScriptAnalysis.SettingsPath; if (!string.Equals(oldScriptAnalysisSettingsPath, newSettingsPath, StringComparison.OrdinalIgnoreCase)) { if (_analysisService != null) { _analysisService.SettingsPath = newSettingsPath; settingsPathChanged = true; } } // If script analysis settings have changed we need to clear & possibly update the current diagnostic records. if ((oldScriptAnalysisEnabled != _configurationService.CurrentSettings.ScriptAnalysis?.Enable) || settingsPathChanged) { // If the user just turned off script analysis or changed the settings path, send a diagnostics // event to clear the analysis markers that they already have. if (!_configurationService.CurrentSettings.ScriptAnalysis.Enable.Value || settingsPathChanged) { foreach (var scriptFile in _workspaceService.GetOpenedFiles()) { _analysisService.ClearMarkers(scriptFile); } } } // Convert the editor file glob patterns into an array for the Workspace // Both the files.exclude and search.exclude hash tables look like (glob-text, is-enabled): // "files.exclude" : { // "Makefile": true, // "*.html": true, // "build/*": true // } var excludeFilePatterns = new List <string>(); if (incomingSettings.Files?.Exclude != null) { foreach (KeyValuePair <string, bool> patternEntry in incomingSettings.Files.Exclude) { if (patternEntry.Value) { excludeFilePatterns.Add(patternEntry.Key); } } } if (incomingSettings.Search?.Exclude != null) { foreach (KeyValuePair <string, bool> patternEntry in incomingSettings.Files.Exclude) { if (patternEntry.Value && !excludeFilePatterns.Contains(patternEntry.Key)) { excludeFilePatterns.Add(patternEntry.Key); } } } _workspaceService.ExcludeFilesGlob = excludeFilePatterns; // Convert the editor file search options to Workspace properties if (incomingSettings.Search?.FollowSymlinks != null) { _workspaceService.FollowSymlinks = incomingSettings.Search.FollowSymlinks; } return(await Unit.Task.ConfigureAwait(false)); }