@@ -10,7 +10,7 @@ import * as vscode from 'vscode';
1010import * as util from '../common' ;
1111import { PersistentFolderState } from './persistentState' ;
1212import { CppSettings } from './settings' ;
13- const configVersion : number = 3 ;
13+ const configVersion : number = 4 ;
1414
1515// No properties are set in the config since we want to apply vscode settings first (if applicable).
1616// That code won't trigger if another value is already set.
@@ -527,31 +527,7 @@ export class CppProperties {
527527 // the system includes were available.
528528 this . configurationIncomplete = false ;
529529
530- // Update intelliSenseMode, compilerPath, cStandard, and cppStandard with the defaults if they're missing.
531- // If VS Code settings exist for these properties, don't add them to c_cpp_properties.json
532530 let dirty : boolean = false ;
533- let settings : CppSettings = new CppSettings ( this . rootUri ) ;
534- for ( let i : number = 0 ; i < this . configurationJson . configurations . length ; i ++ ) {
535- let config : Configuration = this . configurationJson . configurations [ i ] ;
536- if ( config . intelliSenseMode === undefined && ! settings . defaultIntelliSenseMode ) {
537- dirty = true ;
538- config . intelliSenseMode = this . getIntelliSenseModeForPlatform ( config . name ) ;
539- }
540- // Don't set the default if compileCommands exist, until it is fixed to have the correct value.
541- if ( config . compilerPath === undefined && this . defaultCompilerPath && ! config . compileCommands && ! settings . defaultCompilerPath ) {
542- config . compilerPath = this . defaultCompilerPath ;
543- dirty = true ;
544- }
545- if ( ! config . cStandard && this . defaultCStandard && ! settings . defaultCStandard ) {
546- config . cStandard = this . defaultCStandard ;
547- dirty = true ;
548- }
549- if ( ! config . cppStandard && this . defaultCppStandard && ! settings . defaultCppStandard ) {
550- config . cppStandard = this . defaultCppStandard ;
551- dirty = true ;
552- }
553- }
554-
555531 if ( this . configurationJson . version !== configVersion ) {
556532 dirty = true ;
557533 if ( this . configurationJson . version === undefined ) {
@@ -560,6 +536,10 @@ export class CppProperties {
560536
561537 if ( this . configurationJson . version === 2 ) {
562538 this . updateToVersion3 ( ) ;
539+ }
540+
541+ if ( this . configurationJson . version === 3 ) {
542+ this . updateToVersion4 ( ) ;
563543 } else {
564544 this . configurationJson . version = configVersion ;
565545 vscode . window . showErrorMessage ( 'Unknown version number found in c_cpp_properties.json. Some features may not work as expected.' ) ;
@@ -611,6 +591,30 @@ export class CppProperties {
611591 }
612592 }
613593
594+ private updateToVersion4 ( ) : void {
595+ this . configurationJson . version = 4 ;
596+ // Update intelliSenseMode, compilerPath, cStandard, and cppStandard with the defaults if they're missing.
597+ // If VS Code settings exist for these properties, don't add them to c_cpp_properties.json
598+ let settings : CppSettings = new CppSettings ( this . rootUri ) ;
599+ for ( let i : number = 0 ; i < this . configurationJson . configurations . length ; i ++ ) {
600+ let config : Configuration = this . configurationJson . configurations [ i ] ;
601+
602+ if ( config . intelliSenseMode === undefined && ! settings . defaultIntelliSenseMode ) {
603+ config . intelliSenseMode = this . getIntelliSenseModeForPlatform ( config . name ) ;
604+ }
605+ // Don't set the default if compileCommands exist, until it is fixed to have the correct value.
606+ if ( config . compilerPath === undefined && this . defaultCompilerPath && ! config . compileCommands && ! settings . defaultCompilerPath ) {
607+ config . compilerPath = this . defaultCompilerPath ;
608+ }
609+ if ( ! config . cStandard && this . defaultCStandard && ! settings . defaultCStandard ) {
610+ config . cStandard = this . defaultCStandard ;
611+ }
612+ if ( ! config . cppStandard && this . defaultCppStandard && ! settings . defaultCppStandard ) {
613+ config . cppStandard = this . defaultCppStandard ;
614+ }
615+ }
616+ }
617+
614618 public checkCppProperties ( ) : void {
615619 // Check for change properties in case of file watcher failure.
616620 let propertiesFile : string = path . join ( this . configFolder , "c_cpp_properties.json" ) ;
0 commit comments