Skip to content

Commit

Permalink
Add more logging to ConfigurationHandler.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
andyleejordan committed May 19, 2021
1 parent 43f5e1b commit 14352c5
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ public PsesConfigurationHandler(
public override async Task<Unit> Handle(DidChangeConfigurationParams request, CancellationToken cancellationToken)
{
LanguageServerSettingsWrapper incomingSettings = request.Settings.ToObject<LanguageServerSettingsWrapper>();
if(incomingSettings == null)
this._logger.LogTrace("Handling DidChangeConfiguration");
if (incomingSettings == null)
{
this._logger.LogTrace("Incoming settings were null");
return await Unit.Task.ConfigureAwait(false);
}

Expand All @@ -73,16 +75,20 @@ public override async Task<Unit> Handle(DidChangeConfigurationParams request, Ca
if (!string.IsNullOrEmpty(_configurationService.CurrentSettings.Cwd)
&& Directory.Exists(_configurationService.CurrentSettings.Cwd))
{
this._logger.LogTrace($"Setting CWD (from config) to {_configurationService.CurrentSettings.Cwd}");
await _powerShellContextService.SetWorkingDirectoryAsync(
_configurationService.CurrentSettings.Cwd,
isPathAlreadyEscaped: false).ConfigureAwait(false);

} else if (_workspaceService.WorkspacePath != null
&& Directory.Exists(_workspaceService.WorkspacePath))
{
this._logger.LogTrace($"Setting CWD (from workspace) to {_workspaceService.WorkspacePath}");
await _powerShellContextService.SetWorkingDirectoryAsync(
_workspaceService.WorkspacePath,
isPathAlreadyEscaped: false).ConfigureAwait(false);
} else {
this._logger.LogTrace("Tried to set CWD but in bad state");
}

this._cwdSet = true;
Expand All @@ -95,20 +101,24 @@ await _powerShellContextService.SetWorkingDirectoryAsync(
if (_configurationService.CurrentSettings.EnableProfileLoading
&& (!this._profilesLoaded || !profileLoadingPreviouslyEnabled))
{
this._logger.LogTrace("Loading profiles...");
await _powerShellContextService.LoadHostProfilesAsync().ConfigureAwait(false);
this._profilesLoaded = true;
this._logger.LogTrace("Loaded!");
}

// 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
this._logger.LogTrace("Starting command loop");
_powerShellContextService.ConsoleReader.StartCommandLoop();
this._consoleReplStarted = true;
}

// Run any events subscribed to configuration updates
this._logger.LogTrace("Running configuration update event handlers");
ConfigurationUpdated(this, _configurationService.CurrentSettings);

// Convert the editor file glob patterns into an array for the Workspace
Expand Down

0 comments on commit 14352c5

Please sign in to comment.