Skip to content

Commit f8042db

Browse files
committed
Handle redundant 'configurationDone' requests in the DebugAdapter
1 parent e54c091 commit f8042db

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,19 @@ protected async Task HandleConfigurationDoneRequest(
122122
{
123123
if (!string.IsNullOrEmpty(this.scriptPathToLaunch))
124124
{
125-
// Configuration is done, launch the script
126-
var nonAwaitedTask =
127-
this.LaunchScript(requestContext)
128-
.ConfigureAwait(false);
125+
if (this.editorSession.PowerShellContext.SessionState == PowerShellContextState.Ready)
126+
{
127+
// Configuration is done, launch the script
128+
var nonAwaitedTask =
129+
this.LaunchScript(requestContext)
130+
.ConfigureAwait(false);
131+
}
132+
else
133+
{
134+
Logger.Write(
135+
LogLevel.Verbose,
136+
"configurationDone request called after script was already launched, skipping it.");
137+
}
129138
}
130139

131140
await requestContext.SendResult(null);

test/PowerShellEditorServices.Test.Host/DebugAdapterTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ public async Task DebugAdapterReceivesOutputEvents()
122122
private async Task LaunchScript(string scriptPath)
123123
{
124124
await this.debugAdapterClient.LaunchScript(scriptPath);
125-
await this.SendRequest(ConfigurationDoneRequest.Type, null);
126125
}
127126
}
128127
}

0 commit comments

Comments
 (0)