@@ -187,25 +187,6 @@ export class CppProperties {
187187 this . defaultIncludes = compilerDefaults . includes ;
188188 this . defaultFrameworks = compilerDefaults . frameworks ;
189189
190- // Update the compilerPath, cStandard, and cppStandard with the default being used.
191- let doUpdate : boolean = false ;
192- let config : Configuration = this . configurationJson . configurations [ this . CurrentConfiguration ] ;
193- if ( this . defaultCompilerPath && this . defaultCompilerPath . length > 0 && ( ! config . compilerPath || config . compilerPath . length === 0 ) ) {
194- config . compilerPath = this . defaultCompilerPath ;
195- doUpdate = true ;
196- }
197- if ( this . defaultCStandard && this . defaultCStandard . length > 0 && ( ! config . cStandard || config . cStandard . length === 0 ) ) {
198- config . cStandard = this . defaultCStandard ;
199- doUpdate = true ;
200- }
201- if ( this . defaultCppStandard && this . defaultCppStandard . length > 0 && ( ! config . cppStandard || config . cppStandard . length === 0 ) ) {
202- config . cppStandard = this . defaultCppStandard ;
203- doUpdate = true ;
204- }
205- if ( doUpdate && this . propertiesFile ) {
206- fs . writeFileSync ( this . propertiesFile . fsPath , JSON . stringify ( this . configurationJson , null , 4 ) ) ;
207- }
208-
209190 // defaultPaths is only used when there isn't a c_cpp_properties.json, but we don't send the configuration changed event
210191 // to the language server until the default include paths and frameworks have been sent.
211192 this . handleConfigurationChange ( ) ;
@@ -239,9 +220,7 @@ export class CppProperties {
239220 if ( process . platform === 'darwin' ) {
240221 this . configurationJson . configurations [ this . CurrentConfiguration ] . macFrameworkPath = this . defaultFrameworks ;
241222 }
242- if ( this . defaultCompilerPath ) {
243- this . configurationJson . configurations [ this . CurrentConfiguration ] . compilerPath = this . defaultCompilerPath ;
244- }
223+ this . configurationJson . configurations [ this . CurrentConfiguration ] . compilerPath = this . defaultCompilerPath ;
245224 if ( this . defaultCStandard ) {
246225 this . configurationJson . configurations [ this . CurrentConfiguration ] . cStandard = this . defaultCStandard ;
247226 }
@@ -482,6 +461,21 @@ export class CppProperties {
482461 }
483462 }
484463
464+ // Update the compilerPath, cStandard, and cppStandard with the default if they're missing.
465+ let config : Configuration = this . configurationJson . configurations [ this . CurrentConfiguration ] ;
466+ if ( ! config . compilerPath ) {
467+ config . compilerPath = this . defaultCompilerPath ;
468+ dirty = true ;
469+ }
470+ if ( ! config . cStandard ) {
471+ config . cStandard = this . defaultCStandard ;
472+ dirty = true ;
473+ }
474+ if ( ! config . cppStandard ) {
475+ config . cppStandard = this . defaultCppStandard ;
476+ dirty = true ;
477+ }
478+
485479 if ( dirty ) {
486480 fs . writeFileSync ( this . propertiesFile . fsPath , JSON . stringify ( this . configurationJson , null , 4 ) ) ;
487481 }
0 commit comments