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

Add a setting to activate environment in the current open terminal #7665

Merged
merged 1 commit into from
Nov 14, 2019

Conversation

popzxc
Copy link

@popzxc popzxc commented Sep 29, 2019

For #5330

Since a generic solution for that issue is quite hard to imagine, I decided to make this functionality optional.

Thus, people who really wants to get environment activated in the current open terminal, can enable this behavior in settings, and everyone else won't be affected.

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
  • Title summarizes what is changing
  • Has a news entry file (remember to thank yourself!)
  • Appropriate comments and documentation strings in the code
  • Has sufficient logging.
  • Has telemetry for enhancements.
  • Unit tests & system/integration tests are added/updated
  • Test plan is updated as appropriate
  • package-lock.json has been regenerated by running npm install (if dependencies have changed)
  • The wiki is updated with any design decisions/details.

@msftclas
Copy link

msftclas commented Sep 29, 2019

CLA assistant check
All CLA requirements met.

@popzxc
Copy link
Author

popzxc commented Oct 1, 2019

@DonJayamanne can this PR be reviewed?

@DonJayamanne
Copy link

@microsoft/pvsc-team /cc

@karrtikr
Copy link

karrtikr commented Oct 1, 2019

The original issue needs spec, so we'll have to wait from approval from the PMs before we can merge this.

@qubitron
Copy link

qubitron commented Oct 1, 2019

@luabud can do the review / final approval for this, she is out this week if we don't mind waiting until next week to review the setting

@DonJayamanne
Copy link

We might need to add some code to track the usage (telemetry)

@popzxc
Copy link
Author

popzxc commented Oct 15, 2019

@luabud I feel really awkward for reminding about myself again, but can I please get some feedback?

@luabud
Copy link
Member

luabud commented Oct 15, 2019

@popzxc I'm SO sorry for the delay! I got caught up with other tasks and missed this one, my bad 😞 But thank you so much for working on this! It's working great 🎉.

The setting name seems good, I think "python.terminal.activateEnvInCurrentTerminal" describes the intent well. As Don mentioned, it'd be nice if we can add telemetry to track usage - this helps us prioritize maintenance and feature work, and sometimes with error/bug detection 😊.

If I understood it correctly, the terminal is only activated when the extension is activated (i.e. on first launch), is that correct? Although this seems to be the safest approach to take, at least for me the expected behavior would be to activate it every time the interpreter changes (assuming users would only change enable the activateEnvInCurrentTerminal setting if they are aware of its behavior). I believe the worst-case scenario would be if someone is half-way through a command or with a REPL open in the terminal - which would throw errors and the terminal wouldn't be activated, but this is an issue similar to what we already have when e.g. sending selections to the same terminal after the user quits the REPL. What do you all think?

@popzxc
Copy link
Author

popzxc commented Oct 15, 2019

Well, the suggested approach seems completely reasonable to me (I don't really often change the interpreter within workspace, so I just forgot to think about it), I will implement that soon.

Regarding the telemetry question: I think it would be the best if you will guide me which kind of information should be sent, since I don't feel qualified enough to decide on my own.

As I can see it, I can add a variant "activatecurrentterminalsetting" into triggeredBy field of EventName.TERMINAL_CREATE and right before activating the environment in current terminal call:

sendTelemetryEvent(EventName.TERMINAL_CREATE, undefined, { triggeredBy: 'activatecurrentterminalsetting' });

Will that be enough or should it be something else?

@luabud
Copy link
Member

luabud commented Oct 15, 2019

@popzxc this PR brought up a long discussion in the team 😁. First, I created a separate issue for the telemetry work, so that you don't have to worry about it 😊. Secondly, there were some concerns regarding the approach I suggested as well as the current behavior with this PR, and we all agreed we need to discuss it further. We opened an issue so we can investigate the feasibility of a few other options and we'll get back to you once we have a decision (mostly likely in a week or two). And again, thank you so much for working on this 👍.

@popzxc
Copy link
Author

popzxc commented Oct 16, 2019

Sure, no problem :)

@karrtikr karrtikr self-requested a review November 13, 2019 23:25
@luabud
Copy link
Member

luabud commented Nov 13, 2019

Thank you so much for your patience @popzxc! We finished the investigation and we're deciding to go with your approach 😊.
Again, thanks for the contribution 🎉.

Copy link

@karrtikr karrtikr left a comment

Choose a reason for hiding this comment

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

We can merge this now✅

@karrtikr karrtikr merged commit 5f3b14e into microsoft:master Nov 14, 2019
@popzxc popzxc deleted the activate-current-terminal branch November 14, 2019 03:37
@@ -14,6 +15,15 @@ export class TerminalProvider implements Disposable {
constructor(private serviceContainer: IServiceContainer) {
this.registerCommands();
}
public async initialize(currentTerminal: Terminal | undefined) {
const configuration = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
const pythonSettings = configuration.getSettings();
Copy link

@karrtikr karrtikr Nov 18, 2019

Choose a reason for hiding this comment

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

Shoot. Actually the setting added is not a user setting, but a workspace folder setting😅
So while fetching the settings, one have to provide the workspace folder(or the active resource)

Should be configuration.getSettings(this.getActiveResource()) instead. Will do it as part of #8004

Copy link
Author

@popzxc popzxc Nov 19, 2019

Choose a reason for hiding this comment

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

Oh. Didn't expect that.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants