From bdd01439536675fcd584518b9ce5dc34d3a944f1 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Mon, 22 Feb 2021 14:11:34 -0800 Subject: [PATCH 1/4] Fix configuration processing for profile loading --- .../Services/Workspace/Handlers/ConfigurationHandler.cs | 9 ++++++--- .../Services/Workspace/LanguageServerSettings.cs | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs b/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs index d340a54fe..a6326afb8 100644 --- a/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs +++ b/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs @@ -96,9 +96,12 @@ await _powerShellContextService.SetWorkingDirectoryAsync( this._cwdSet = true; } - if (!this._profilesLoaded && - _configurationService.CurrentSettings.EnableProfileLoading && - oldLoadProfiles != _configurationService.CurrentSettings.EnableProfileLoading) + // 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 || !oldLoadProfiles)) { await _powerShellContextService.LoadHostProfilesAsync().ConfigureAwait(false); this._profilesLoaded = true; diff --git a/src/PowerShellEditorServices/Services/Workspace/LanguageServerSettings.cs b/src/PowerShellEditorServices/Services/Workspace/LanguageServerSettings.cs index f6b1b3314..2f17e2b56 100644 --- a/src/PowerShellEditorServices/Services/Workspace/LanguageServerSettings.cs +++ b/src/PowerShellEditorServices/Services/Workspace/LanguageServerSettings.cs @@ -19,7 +19,7 @@ internal class LanguageServerSettings { private readonly object updateLock = new object(); - public bool EnableProfileLoading { get; set; } = true; + public bool EnableProfileLoading { get; set; }; public bool PromptToUpdatePackageManagement { get; set; } = true; From fe1dc6d7a36b98c33f9d716356ab139b273c22d1 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Mon, 22 Feb 2021 14:22:32 -0800 Subject: [PATCH 2/4] Fix style --- .../Services/Workspace/Handlers/ConfigurationHandler.cs | 4 ++-- .../Services/Workspace/LanguageServerSettings.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs b/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs index a6326afb8..f5fcdf84a 100644 --- a/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs +++ b/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs @@ -65,7 +65,7 @@ public async Task Handle(DidChangeConfigurationParams request, Cancellatio SendFeatureChangesTelemetry(incomingSettings); - bool oldLoadProfiles = _configurationService.CurrentSettings.EnableProfileLoading; + bool profileLoadingPreviouslyEnabled = _configurationService.CurrentSettings.EnableProfileLoading; bool oldScriptAnalysisEnabled = _configurationService.CurrentSettings.ScriptAnalysis.Enable ?? false; string oldScriptAnalysisSettingsPath = @@ -101,7 +101,7 @@ await _powerShellContextService.SetWorkingDirectoryAsync( // - Profiles haven't been loaded before, OR // - The profile loading configuration just changed if (_configurationService.CurrentSettings.EnableProfileLoading - && (!this._profilesLoaded || !oldLoadProfiles)) + && (!this._profilesLoaded || !profileLoadingPreviouslyEnabled)) { await _powerShellContextService.LoadHostProfilesAsync().ConfigureAwait(false); this._profilesLoaded = true; diff --git a/src/PowerShellEditorServices/Services/Workspace/LanguageServerSettings.cs b/src/PowerShellEditorServices/Services/Workspace/LanguageServerSettings.cs index 2f17e2b56..0dcca5ce4 100644 --- a/src/PowerShellEditorServices/Services/Workspace/LanguageServerSettings.cs +++ b/src/PowerShellEditorServices/Services/Workspace/LanguageServerSettings.cs @@ -19,7 +19,7 @@ internal class LanguageServerSettings { private readonly object updateLock = new object(); - public bool EnableProfileLoading { get; set; }; + public bool EnableProfileLoading { get; set; } = false; public bool PromptToUpdatePackageManagement { get; set; } = true; From d880dc35bd09d3b05c1c60f3ad6b43d9db30f001 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Mon, 22 Feb 2021 15:45:37 -0800 Subject: [PATCH 3/4] Try to fix help tests on Ubuntu --- PowerShellEditorServices.build.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 9934646ae..831d03da8 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -224,10 +224,15 @@ namespace Microsoft.PowerShell.EditorServices.Hosting Set-Content -LiteralPath $script:BuildInfoPath -Value $buildInfoContents -Force } -task SetupHelpForTests -Before Test { +task SetupHelpForTests { if (-not (Get-Help Write-Host).Examples) { + Write-Host "Updating help for tests" Update-Help -Module Microsoft.PowerShell.Utility -Force -Scope CurrentUser } + else + { + Write-Host "Write-Host help found -- Update-Help skipped" + } } task Build BinClean,{ @@ -247,7 +252,7 @@ function DotNetTestFilter { if ($TestFilter) { @("--filter",$TestFilter) } else { "" } } -task Test TestServer,TestE2E +task Test SetupHelpForTest,TestServer,TestE2E task TestServer TestServerWinPS,TestServerPS7,TestServerPS71 From 123cb64b0958b95fd7597266fefe007c44a7b667 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Mon, 22 Feb 2021 15:55:23 -0800 Subject: [PATCH 4/4] Fix typo in build script --- PowerShellEditorServices.build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 831d03da8..9d37cbe5e 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -252,7 +252,7 @@ function DotNetTestFilter { if ($TestFilter) { @("--filter",$TestFilter) } else { "" } } -task Test SetupHelpForTest,TestServer,TestE2E +task Test SetupHelpForTests,TestServer,TestE2E task TestServer TestServerWinPS,TestServerPS7,TestServerPS71