Skip to content
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

Using F8 causes the code editor to lose cursor/selection focus so F8 cannot be used again to run the same code #3887

Closed
5 of 6 tasks
ALIENQuake opened this issue Mar 23, 2022 · 3 comments
Labels
Area-UI Issue-Enhancement A feature request (enhancement). Up for Grabs Will shepherd PRs.

Comments

@ALIENQuake
Copy link

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Hi,

Using F8 causes the code editor to lose cursor/selection focus so F8 cannot be used again to run the same code.

PowerShell Version

PSVersion                      7.2.2
PSEdition                      Core
GitCommitId                    7.2.2
OS                             Microsoft Windows 10.0.22579
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.65.2
c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1
x64

Extension Version

ms-vscode.powershell-preview@2022.3.0

Steps to Reproduce

  1. Select code
  2. Press F8
  3. Press F8 again, no code is executed

Visuals

No response

Logs

No response

@ALIENQuake ALIENQuake added the Issue-Bug A bug to squash. label Mar 23, 2022
@ghost ghost added the Needs: Triage Maintainer attention needed! label Mar 23, 2022
@andyleejordan
Copy link
Member

I believe this is by design: it moves the focus to the terminal because it's executed code in the terminal (which may require user input). So I think is more of a feature request to add the ability to configure if the focus should change or not. In fact, if the integrated console is not the current terminal, it looks like we already have some logic to respect VS Code's own setting focusConsoleOnExecute:

constructor(private log: Logger) {
super();
this.commands = [
vscode.commands.registerCommand("PowerShell.RunSelection", async () => {
if (vscode.window.activeTerminal &&
vscode.window.activeTerminal.name !== "PowerShell Integrated Console") {
this.log.write("PSIC is not active terminal. Running in active terminal using 'runSelectedText'");
await vscode.commands.executeCommand("workbench.action.terminal.runSelectedText");
// We need to honor the focusConsoleOnExecute setting here too. However, the boolean that `show`
// takes is called `preserveFocus` which when `true` the terminal will not take focus.
// This is the inverse of focusConsoleOnExecute so we have to inverse the boolean.
vscode.window.activeTerminal.show(!Settings.load().integratedConsole.focusConsoleOnExecute);
await vscode.commands.executeCommand("workbench.action.terminal.scrollToBottom");
return;
}
const editor = vscode.window.activeTextEditor;
let selectionRange: vscode.Range;
if (!editor.selection.isEmpty) {
selectionRange =
new vscode.Range(
editor.selection.start,
editor.selection.end);
} else {
selectionRange = editor.document.lineAt(editor.selection.start.line).range;
}
this.languageClient.sendRequest(EvaluateRequestType, {
expression: editor.document.getText(selectionRange),
});
// Show the integrated console if it isn't already visible and
// scroll terminal to bottom so new output is visible
await vscode.commands.executeCommand("PowerShell.ShowSessionConsole", true);
await vscode.commands.executeCommand("workbench.action.terminal.scrollToBottom");
}),
];
}

@andyleejordan andyleejordan added Issue-Enhancement A feature request (enhancement). Up for Grabs Will shepherd PRs. Area-UI and removed Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! labels Mar 24, 2022
@andyleejordan andyleejordan added this to To Do in VS Code Compatibility via automation Mar 24, 2022
@andyleejordan andyleejordan added this to the Consider-vNext milestone Mar 24, 2022
@SydneyhSmith
Copy link
Collaborator

thanks @ALIENQuake does the setting "powershell.integratedConsole.focusConsoleOnExecute": false, resolve this for you?

@ALIENQuake
Copy link
Author

@SydneyhSmith Yep, I had this setting turned on and I forgot it even existed. Sorry!

VS Code Compatibility automation moved this from To Do to Done May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-UI Issue-Enhancement A feature request (enhancement). Up for Grabs Will shepherd PRs.
Projects
No open projects
Development

No branches or pull requests

3 participants