-
Notifications
You must be signed in to change notification settings - Fork 241
Consolidate InterruptCurrentForeground and MustRunInForeground
#1777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
And set them consistently. If the task needs to interrupt or run in the foreground, it really needs to do both.
|
This was tested on top of #1778 and good to go @SeeminglyScience |
SeeminglyScience
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…ound` (PowerShell#1777)" This reverts commit 39c9ed4.
| // This API is mostly used for F5 execution so it requires the foreground. | ||
| private static readonly PowerShellExecutionOptions s_debuggerExecutionOptions = new() | ||
| { | ||
| MustRunInForeground = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SeeminglyScience just looking back at this PR, knowing what we know now, we've moved F5 to priority next (seems right to me!)
| WriteOutputToHost = !editorCommand.SuppressOutput, | ||
| AddToHistory = !editorCommand.SuppressOutput, | ||
| ThrowOnError = false, | ||
| InterruptCurrentForeground = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Editor command execution was already going to run with priority next.
| _psrlProxy.OverrideIdleHandler(onIdleAction); | ||
| } | ||
|
|
||
| public override string ReadLine(CancellationToken cancellationToken) => _psesHost.InvokeDelegate(representation: "ReadLine", new ExecutionOptions { MustRunInForeground = true }, InvokePSReadLine, cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReadLine will now run with priority next (again, seems right!)
| WriteOutputToHost = true, | ||
| AddToHistory = true, | ||
| ThrowOnError = false, | ||
| InterruptCurrentForeground = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F8 was already going to run with priority next, which F5 now matches.
| // TODO: Why exactly does loading profiles require the foreground? | ||
| return ExecuteDelegateAsync( | ||
| "LoadProfiles", | ||
| new PowerShellExecutionOptions { MustRunInForeground = true, ThrowOnError = false }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is what caused us trouble. Profiles was not going to run with priority next, which it then started running with, ahead of psEditor. We've fixed that by not specifying foreground at all, since this is a startup task.
Heck: should we add an "isStartup" task that only runs in the startup loop, and throws an error for us if it's encountered anywhere else?
| // we simply run this on its thread, guaranteeing that no other action can occur | ||
| return ExecuteDelegateAsync( | ||
| nameof(PopOrReinitializeRunspaceAsync), | ||
| new ExecutionOptions { InterruptCurrentForeground = true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PopOrReinitialize w as already going to run with priority next.
| await _executionService.ExecutePSCommandAsync( | ||
| command, | ||
| CancellationToken.None, | ||
| new PowerShellExecutionOptions { WriteOutputToHost = true, InterruptCurrentForeground = true, ThrowOnError = false }).ConfigureAwait(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As was the Invoke-Plaster.
And set them consistently. If the task needs to interrupt or run in the foreground, it really needs to do both. Also fixes some indentation.