Skip to content

null check on activeTerminal to workaround vscode behavior #2141

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

Merged
merged 2 commits into from
Sep 16, 2019

Conversation

TylerLeonhardt
Copy link
Member

PR Summary

fixes #2137

For some reason, there is no active terminal until you click inside of the terminal so this protects against vscode.window.activeTerminal not being defined and will default to running the code in the PSIC

PR Checklist

Note: Tick the boxes below that apply to this pull request by putting an x between the square brackets.
Please mark anything not applicable to this PR NA.

  • PR has a meaningful title
  • Summarized changes
  • PR has tests
  • This PR is ready to merge and is not work in progress
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready

@@ -211,7 +211,8 @@ export class ConsoleFeature implements IFeature {
return;
}

if (vscode.window.activeTerminal.name !== "PowerShell Integrated Console") {
if (vscode.window.activeTerminal &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this flow be better?

if (!activeTerminal && existingPsExtTerminal) {
  // ShowSessionConsole
  return;
}
if (!activeTerminal || activeTerminal !== "PowerShell Integrated Console") {
  // Use runSelectedText
  return;
}
// ShowSessionConsole

Copy link
Member Author

Choose a reason for hiding this comment

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

@Tyriar I'm guessing from your snippet that existingPsExtTerminal would be used to determine if the PS extensions terminal is the "active"/"visible" terminal?

@TylerLeonhardt TylerLeonhardt merged commit e2e322f into master Sep 16, 2019
@TylerLeonhardt TylerLeonhardt deleted the null-check-activeterminal branch September 16, 2019 19:45
TylerLeonhardt added a commit to TylerLeonhardt/vscode-powershell that referenced this pull request Sep 16, 2019
…l#2141)

* null check on activeTerminal

* newline for linting
TylerLeonhardt added a commit that referenced this pull request Sep 17, 2019
…2178)

* null check on activeTerminal

* newline for linting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PowerShell preview extension does not allow running selection from undefined files
2 participants