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

Unclear what append vs prepend vs replace do #183834

Closed
meganrogge opened this issue May 30, 2023 · 1 comment
Closed

Unclear what append vs prepend vs replace do #183834

meganrogge opened this issue May 30, 2023 · 1 comment
Assignees

Comments

@meganrogge
Copy link
Contributor

Testing #182970

Unclear what append vs prepend vs replace do 🤔

Running this command and relaunching the terminal yields this env

	context.subscriptions.push(vscode.commands.registerCommand('terminalTest.updateEnvironment', () => {
		const collection = context.environmentVariableCollection;
		collection.replace('FOO', 'REPLACED');
		collection.append('APPENDING', 'appending')
		collection.prepend('PREPENDING', 'prepending');
	}));

i was expecting to see PREPENDING at the beginning of the env or at least before the others and the inverse for APPENDING

Screenshot 2023-05-30 at 11 36 33 AM

@Tyriar
Copy link
Member

Tyriar commented May 30, 2023

It's nothing to do with the order of the environment, it's how they are applied to the existing variable's value. I think this is already covered by the jsdocs in the stable API as it's referred to as "an environment variable", not environment. I'm guessing you were only looking at the proposal docs?

vscode/src/vscode-dts/vscode.d.ts

Lines 11267 to 11298 in 44b766d

/**
* Replace an environment variable with a value.
*
* Note that an extension can only make a single change to any one variable, so this will
* overwrite any previous calls to replace, append or prepend.
*
* @param variable The variable to replace.
* @param value The value to replace the variable with.
*/
replace(variable: string, value: string): void;
/**
* Append a value to an environment variable.
*
* Note that an extension can only make a single change to any one variable, so this will
* overwrite any previous calls to replace, append or prepend.
*
* @param variable The variable to append to.
* @param value The value to append to the variable.
*/
append(variable: string, value: string): void;
/**
* Prepend a value to an environment variable.
*
* Note that an extension can only make a single change to any one variable, so this will
* overwrite any previous calls to replace, append or prepend.
*
* @param variable The variable to prepend.
* @param value The value to prepend to the variable.
*/
prepend(variable: string, value: string): void;

@Tyriar Tyriar closed this as completed May 30, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jul 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants