Skip to content

Commit d99fbb6

Browse files
authored
Fix session details gathering in nested prompts
Fix session details gathering in nested prompts
2 parents 131e51f + 271df79 commit d99fbb6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/PowerShellEditorServices/Session/PowerShellContext.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,18 @@ private SessionDetails GetSessionDetailsInDebugger()
19301930

19311931
private SessionDetails GetSessionDetailsInNestedPipeline()
19321932
{
1933-
return GetSessionDetailsInRunspace(this.CurrentRunspace.Runspace);
1933+
// We don't need to check what thread we're on here. If it's a local
1934+
// nested pipeline then we will already be on the correct thread, and
1935+
// non-debugger nested pipelines aren't supported in remote runspaces.
1936+
return this.GetSessionDetails(
1937+
command =>
1938+
{
1939+
using (var localPwsh = PowerShell.Create(RunspaceMode.CurrentRunspace))
1940+
{
1941+
localPwsh.Commands = command;
1942+
return localPwsh.Invoke().FirstOrDefault();
1943+
}
1944+
});
19341945
}
19351946

19361947
private void SetProfileVariableInCurrentRunspace(ProfilePaths profilePaths)

0 commit comments

Comments
 (0)