|
17 | 17 | using OmniSharp.Extensions.LanguageServer.Protocol.Server; |
18 | 18 | using OmniSharp.Extensions.LanguageServer.Protocol.Window; |
19 | 19 | using OmniSharp.Extensions.LanguageServer.Protocol.Workspace; |
20 | | -using System.IO; |
21 | | -using Microsoft.PowerShell.EditorServices.Services.PowerShell; |
22 | 20 | using Microsoft.PowerShell.EditorServices.Services.PowerShell.Host; |
23 | 21 | using Microsoft.PowerShell.EditorServices.Services.Extension; |
24 | 22 |
|
@@ -81,14 +79,35 @@ public override async Task<Unit> Handle(DidChangeConfigurationParams request, Ca |
81 | 79 | _workspaceService.WorkspacePath, |
82 | 80 | _logger); |
83 | 81 |
|
| 82 | + // We need to load the profiles if: |
| 83 | + // - Profile loading is configured, AND |
| 84 | + // - Profiles haven't been loaded before, OR |
| 85 | + // - The profile loading configuration just changed |
| 86 | + bool loadProfiles = _configurationService.CurrentSettings.EnableProfileLoading |
| 87 | + && (!_profilesLoaded || !profileLoadingPreviouslyEnabled); |
| 88 | + |
84 | 89 | if (!_psesHost.IsRunning) |
85 | 90 | { |
86 | | - await _psesHost.StartAsync(new HostStartOptions |
| 91 | + _logger.LogTrace("Starting command loop"); |
| 92 | + |
| 93 | + if (loadProfiles) |
87 | 94 | { |
88 | | - LoadProfiles = _configurationService.CurrentSettings.EnableProfileLoading, |
89 | | - }, CancellationToken.None).ConfigureAwait(false); |
| 95 | + _logger.LogTrace("Loading profiles..."); |
| 96 | + } |
| 97 | + |
| 98 | + await _psesHost.StartAsync(new HostStartOptions(), CancellationToken.None).ConfigureAwait(false); |
| 99 | + |
| 100 | + _consoleReplStarted = true; |
| 101 | + |
| 102 | + if (loadProfiles) |
| 103 | + { |
| 104 | + _profilesLoaded = true; |
| 105 | + _logger.LogTrace("Loaded!"); |
| 106 | + } |
90 | 107 | } |
91 | 108 |
|
| 109 | + // TODO: Load profiles when the host is already running |
| 110 | + |
92 | 111 | if (!this._cwdSet) |
93 | 112 | { |
94 | 113 | if (!string.IsNullOrEmpty(_configurationService.CurrentSettings.Cwd) |
@@ -116,33 +135,6 @@ await _psesHost.SetInitialWorkingDirectoryAsync( |
116 | 135 | this._cwdSet = true; |
117 | 136 | } |
118 | 137 |
|
119 | | - // We need to load the profiles if: |
120 | | - // - Profile loading is configured, AND |
121 | | - // - Profiles haven't been loaded before, OR |
122 | | - // - The profile loading configuration just changed |
123 | | - bool loadProfiles = _configurationService.CurrentSettings.EnableProfileLoading |
124 | | - && (!_profilesLoaded || !profileLoadingPreviouslyEnabled); |
125 | | - |
126 | | - if (!_psesHost.IsRunning) |
127 | | - { |
128 | | - _logger.LogTrace("Starting command loop"); |
129 | | - |
130 | | - if (loadProfiles) |
131 | | - { |
132 | | - _logger.LogTrace("Loading profiles..."); |
133 | | - } |
134 | | - |
135 | | - await _psesHost.StartAsync(new HostStartOptions |
136 | | - { |
137 | | - LoadProfiles = loadProfiles, |
138 | | - }, CancellationToken.None).ConfigureAwait(false); |
139 | | - |
140 | | - _consoleReplStarted = true; |
141 | | - _profilesLoaded = loadProfiles; |
142 | | - |
143 | | - _logger.LogTrace("Loaded!"); |
144 | | - } |
145 | | - |
146 | 138 | if (!_extensionServiceInitialized) |
147 | 139 | { |
148 | 140 | await _extensionService.InitializeAsync(); |
|
0 commit comments