Skip to content

Conversation

@andyleejordan
Copy link
Member

@andyleejordan andyleejordan commented Apr 27, 2022

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.

And set them consistently. If the task needs to interrupt or run in the
foreground, it really needs to do both.
@andyleejordan andyleejordan added the Ignore Exclude from the changelog. label Apr 27, 2022
@andyleejordan andyleejordan requested a review from a team April 27, 2022 18:21
@andyleejordan
Copy link
Member Author

This was tested on top of #1778 and good to go @SeeminglyScience

@andyleejordan andyleejordan enabled auto-merge (squash) April 27, 2022 21:09
Copy link
Collaborator

@SeeminglyScience SeeminglyScience left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@andyleejordan andyleejordan merged commit 39c9ed4 into master Apr 27, 2022
@andyleejordan andyleejordan deleted the andschwa/requires-foreground branch April 27, 2022 22:58
SeeminglyScience added a commit to SeeminglyScience/PowerShellEditorServices that referenced this pull request Apr 28, 2022
@andyleejordan andyleejordan added Issue-Enhancement A feature request (enhancement). Area-Engine and removed Ignore Exclude from the changelog. labels Apr 28, 2022
// This API is mostly used for F5 execution so it requires the foreground.
private static readonly PowerShellExecutionOptions s_debuggerExecutionOptions = new()
{
MustRunInForeground = true,
Copy link
Member Author

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
Copy link
Member Author

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);
Copy link
Member Author

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
Copy link
Member Author

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 },
Copy link
Member Author

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 },
Copy link
Member Author

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);
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Engine Issue-Enhancement A feature request (enhancement).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants