@@ -145,7 +145,7 @@ export class CppProperties {
145145public get Configurations ( ) :Configuration [ ] { return this . configurationJson . configurations ; }
146146public get CurrentConfigurationIndex ( ) :number { return this . currentConfigurationIndex . Value ; }
147147public get CurrentConfiguration ( ) :Configuration { return this . Configurations [ this . CurrentConfigurationIndex ] ; }
148-
148+
149149public get CurrentConfigurationProvider ( ) :string | null {
150150if ( this . CurrentConfiguration . configurationProvider ) {
151151return this . CurrentConfiguration . configurationProvider ;
@@ -202,6 +202,7 @@ export class CppProperties {
202202
203203private resetToDefaultSettings ( resetIndex :boolean ) :void {
204204this . configurationJson = getDefaultCppProperties ( ) ;
205+ this . extendConfigurationEnvironment ( ) ;
205206if ( resetIndex || this . CurrentConfigurationIndex < 0 ||
206207this . CurrentConfigurationIndex >= this . configurationJson . configurations . length ) {
207208this . currentConfigurationIndex . Value = this . getConfigIndexForPlatform ( this . configurationJson ) ;
@@ -252,6 +253,14 @@ export class CppProperties {
252253}
253254}
254255
256+ private extendConfigurationEnvironment ( ) :void {
257+ if ( ! this . configurationJson . env ) {
258+ this . configurationJson . env = { } ;
259+ }
260+
261+ this . configurationJson . env [ "workspaceFolderBasename" ] = path . basename ( this . rootUri . fsPath ) ;
262+ }
263+
255264private async buildVcpkgIncludePath ( ) :Promise < void > {
256265try {
257266// Check for vcpkgRoot and include relevent paths if found.
@@ -611,11 +620,9 @@ export class CppProperties {
611620delete this . configurationJson . env [ 'workspaceRoot' ] ;
612621delete this . configurationJson . env [ 'workspaceFolder' ] ;
613622delete this . configurationJson . env [ 'default' ] ;
614- } else {
615- this . configurationJson . env = { } ;
616623}
617624
618- this . configurationJson . env [ "workspaceFolderBasename" ] = path . basename ( this . rootUri . fsPath ) ;
625+ this . extendConfigurationEnvironment ( ) ;
619626
620627// Warning: There is a chance that this is incorrect in the event that the c_cpp_properties.json file was created before
621628// the system includes were available.
@@ -630,7 +637,7 @@ export class CppProperties {
630637if ( this . configurationJson . version === 2 ) {
631638this . updateToVersion3 ( ) ;
632639}
633-
640+
634641if ( this . configurationJson . version === 3 ) {
635642this . updateToVersion4 ( ) ;
636643} else {