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

Should debug integrated terminal support pass the env directly to createTerminal? #77111

Closed
Tyriar opened this issue Jul 10, 2019 · 3 comments
Closed
Assignees
Labels
debt Code quality issues debug Debug viewlet, configurations, breakpoints, adapter issues
Milestone

Comments

@Tyriar
Copy link
Member

Tyriar commented Jul 10, 2019

Looking at this:

if (args.env) {
for (let key in args.env) {
const value = args.env[key];
if (value === null) {
command += `Remove-Item env:${key}; `;
} else {
command += `\${env:${key}}='${value}'; `;
}
}
}

It looks like it would be a lot simpler to pass in env to createTerminal instead of constructing a per-shell command to set/unset them:

vscode/src/vs/vscode.d.ts

Lines 7106 to 7109 in 4d02d83

/**
* Object with environment variables that will be added to the VS Code process.
*/
env?: { [key: string]: string | null };

@weinand weinand added the debug Debug viewlet, configurations, breakpoints, adapter issues label Jul 26, 2019
@weinand weinand added this to the July 2019 milestone Jul 26, 2019
@weinand
Copy link
Contributor

weinand commented Jul 26, 2019

@Tyriar Debug tries to reuse a terminal if it is "free", i.e. if there are no child processes running in it.
So the terminal is created for the first "runInTerminal" and then reused (if possible).
Consequently passing env to createTerminal only works for the first "runInTerminal". Subsequent "runInTerminal" requests still require the current approach.

@weinand
Copy link
Contributor

weinand commented Jul 26, 2019

@Tyriar for addressing this issue I'm trying to use the terminalService.createTerminalFromOptions API. When filling up the option bag, I can use "getDefaultShell". But why is the corresponding "_getDefaultShellArgs" private?

const options: vscode.TerminalOptions = {
	shellPath: this._terminalService.getDefaultShell(configProvider),
	shellArgs: this._terminalService._getDefaultShellArgs(configProvider),
	cwd: args.cwd,
	name: args.title || nls.localize('debug.terminal.title', "debuggee"),
	env: args.env
};
delete args.cwd;
delete args.env;
this._integratedTerminalInstance = this._terminalService.createTerminalFromOptions(options);

@Tyriar
Copy link
Member Author

Tyriar commented Jul 26, 2019

@weinand it just didn't have any consumers outside yet, whereas the default shell is exposed in the API via env.shell, feel free to change it to public

@weinand weinand added the debt Code quality issues label Jul 29, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debt Code quality issues debug Debug viewlet, configurations, breakpoints, adapter issues
Projects
None yet
Development

No branches or pull requests

2 participants