@@ -762,8 +762,14 @@ export class CppProperties {
762762 }
763763 paths = this . resolveDefaults ( paths , defaultValue ) ;
764764 paths . forEach ( entry => {
765- const entries : string [ ] = util . resolveVariables ( entry , env ) . split ( path . delimiter ) . map ( e => glob ? this . resolvePath ( e , false ) : e ) . filter ( e => e ) ;
766- resolvedVariables . push ( ...entries ) ;
765+ const resolvedVariable : string = util . resolveVariables ( entry , env ) ;
766+ if ( resolvedVariable . includes ( "env:" ) ) {
767+ // Do not futher try to resolve a "${env:VAR}"
768+ resolvedVariables . push ( resolvedVariable ) ;
769+ } else {
770+ const entries : string [ ] = resolvedVariable . split ( path . delimiter ) . map ( e => glob ? this . resolvePath ( e , false ) : e ) . filter ( e => e ) ;
771+ resolvedVariables . push ( ...entries ) ;
772+ }
767773 } ) ;
768774 if ( ! glob ) {
769775 return resolvedVariables ;
@@ -1487,7 +1493,7 @@ export class CppProperties {
14871493 return success ;
14881494 }
14891495
1490- public resolvePath ( input_path : string | undefined , replaceAsterisks : boolean = true ) : string {
1496+ private resolvePath ( input_path : string | undefined , replaceAsterisks : boolean = true ) : string {
14911497 if ( ! input_path || input_path === "${default}" ) {
14921498 return "" ;
14931499 }
@@ -1511,8 +1517,9 @@ export class CppProperties {
15111517 result = result . replace ( / \* / g, "" ) ;
15121518 }
15131519
1514- // Make sure all paths result to an absolute path
1515- if ( ! path . isAbsolute ( result ) && this . rootUri ) {
1520+ // Make sure all paths result to an absolute path.
1521+ // Do not add the root path to an unresolved env variable.
1522+ if ( ! result . includes ( "env:" ) && ! path . isAbsolute ( result ) && this . rootUri ) {
15161523 result = path . join ( this . rootUri . fsPath , result ) ;
15171524 }
15181525
0 commit comments