File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,14 +29,16 @@ export function addPyocdToPath(context: vscode.ExtensionContext): void {
2929 logger . debug ( 'pyOCD is not available' ) ;
3030 return ;
3131 }
32- //get PATH variable
33- const pathVariable = process . env . PATH ;
34- if ( ! pathVariable ) {
35- logger . debug ( 'pyOCD is not available' ) ;
32+ const delimiter = isWindows ? ';' : ':' ;
33+ const updatePath = `${ pathPyOCD } ${ delimiter } ` ;
34+ //get current environment variable collection
35+ const mutator = context . environmentVariableCollection . get ( 'PATH' ) ;
36+ // Path included and previously used type was 'Prepend'. Change mutator
37+ // if other type (we previously used 'Replace' which caused trouble).
38+ if ( mutator ?. type === vscode . EnvironmentVariableMutatorType . Prepend && mutator ?. value . includes ( updatePath ) ) {
39+ // Nothing to update
3640 return ;
3741 }
38- const delimiter = isWindows ? ';' : ':' ;
39- const updatePath = pathPyOCD . concat ( delimiter , pathVariable ) ;
4042 //add updated path to PATH variable, but only for the terminal inside of vscode
41- context . environmentVariableCollection . replace ( 'PATH' , updatePath ) ;
43+ context . environmentVariableCollection . prepend ( 'PATH' , updatePath ) ;
4244}
You can’t perform that action at this time.
0 commit comments