@@ -10,7 +10,7 @@ import * as vscode from 'vscode';
10
10
import * as util from '../common' ;
11
11
import { PersistentFolderState } from './persistentState' ;
12
12
import { CppSettings } from './settings' ;
13
- const configVersion : number = 3 ;
13
+ const configVersion : number = 4 ;
14
14
15
15
// No properties are set in the config since we want to apply vscode settings first (if applicable).
16
16
// That code won't trigger if another value is already set.
@@ -527,31 +527,7 @@ export class CppProperties {
527
527
// the system includes were available.
528
528
this . configurationIncomplete = false ;
529
529
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
532
530
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
-
555
531
if ( this . configurationJson . version !== configVersion ) {
556
532
dirty = true ;
557
533
if ( this . configurationJson . version === undefined ) {
@@ -560,6 +536,10 @@ export class CppProperties {
560
536
561
537
if ( this . configurationJson . version === 2 ) {
562
538
this . updateToVersion3 ( ) ;
539
+ }
540
+
541
+ if ( this . configurationJson . version === 3 ) {
542
+ this . updateToVersion4 ( ) ;
563
543
} else {
564
544
this . configurationJson . version = configVersion ;
565
545
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 {
611
591
}
612
592
}
613
593
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
+
614
618
public checkCppProperties ( ) : void {
615
619
// Check for change properties in case of file watcher failure.
616
620
let propertiesFile : string = path . join ( this . configFolder , "c_cpp_properties.json" ) ;
0 commit comments