Skip to content

Commit def819e

Browse files
committed
Enable host with no repl
1 parent 61ae8f2 commit def819e

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs

+33-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,39 @@ private void RunTopLevelExecutionLoop()
471471
task.ExecuteSynchronously(CancellationToken.None);
472472
}
473473

474-
RunExecutionLoop();
474+
if (_hostInfo.ConsoleReplEnabled)
475+
{
476+
RunExecutionLoop();
477+
}
478+
else
479+
{
480+
RunNoPromptExecutionLoop();
481+
}
482+
}
483+
484+
private void RunNoPromptExecutionLoop()
485+
{
486+
while (!_shouldExit)
487+
{
488+
using (CancellationScope cancellationScope = _cancellationContext.EnterScope(isIdleScope: false))
489+
{
490+
string taskRepresentation = null;
491+
try
492+
{
493+
ISynchronousTask task = _taskQueue.Take(cancellationScope.CancellationToken);
494+
taskRepresentation = task.ToString();
495+
task.ExecuteSynchronously(cancellationScope.CancellationToken);
496+
}
497+
catch (OperationCanceledException)
498+
{
499+
// Just continue
500+
}
501+
catch (Exception e)
502+
{
503+
_logger.LogError(e, $"Fatal exception occurred with task '{taskRepresentation ?? "<null task>"}'");
504+
}
505+
}
506+
}
475507
}
476508

477509
private void RunDebugExecutionLoop()

0 commit comments

Comments
 (0)