@@ -12,7 +12,7 @@ import * as telemetry from '../telemetry';
1212import { PersistentFolderState } from './persistentState' ;
1313import { CppSettings , OtherSettings } from './settings' ;
1414import { ABTestSettings , getABTestSettings } from '../abTesting' ;
15- import { getCustomConfigProviders } from './customProviders' ;
15+ import { CustomConfigurationProviderCollection , getCustomConfigProviders } from './customProviders' ;
1616import { SettingsPanel } from './settingsPanel' ;
1717import * as os from 'os' ;
1818import escapeStringRegExp = require( 'escape-string-regexp' ) ;
@@ -708,6 +708,27 @@ export class CppProperties {
708708
709709configuration . browse . limitSymbolsToIncludedHeaders = this . updateConfigurationStringOrBoolean ( configuration . browse . limitSymbolsToIncludedHeaders , settings . defaultLimitSymbolsToIncludedHeaders , env ) ;
710710configuration . browse . databaseFilename = this . updateConfigurationString ( configuration . browse . databaseFilename , settings . defaultDatabaseFilename , env ) ;
711+
712+ // If there is no c_cpp_properties.json, there are no relevant C_Cpp.default.* settings set,
713+ // and there is only 1 registered custom config provider, default to using that provider.
714+ const providers :CustomConfigurationProviderCollection = getCustomConfigProviders ( ) ;
715+ if ( providers . size === 1
716+ && ! this . propertiesFile
717+ && ! settings . defaultCompilerPath
718+ && settings . defaultCompilerPath !== ""
719+ && ! settings . defaultIncludePath
720+ && ! settings . defaultDefines
721+ && ! settings . defaultMacFrameworkPath
722+ && settings . defaultWindowsSdkVersion === ""
723+ && ! settings . defaultForcedInclude
724+ && settings . defaultCompileCommands === ""
725+ && ! settings . defaultCompilerArgs
726+ && settings . defaultCStandard === ""
727+ && settings . defaultCppStandard === ""
728+ && settings . defaultIntelliSenseMode === ""
729+ && settings . defaultConfigurationProvider === "" ) {
730+ providers . forEach ( provider => { configuration . configurationProvider = provider . extensionId ; } ) ;
731+ }
711732}
712733
713734this . updateCompileCommandsFileWatchers ( ) ;
@@ -898,7 +919,7 @@ export class CppProperties {
898919}
899920}
900921
901- private handleConfigurationChange ( ) :void {
922+ public handleConfigurationChange ( ) :void {
902923if ( this . propertiesFile === undefined ) {
903924return ; // Occurs when propertiesFile hasn't been checked yet.
904925}
@@ -941,18 +962,21 @@ export class CppProperties {
941962}
942963
943964const fullPathToFile :string = path . join ( this . configFolder , "c_cpp_properties.json" ) ;
965+ // Since the properties files does not exist, there will be exactly 1 configuration.
966+ // If we have decided to use a custom config provider, propagate that to the new config.
967+ const settings :CppSettings = new CppSettings ( this . rootUri ) ;
968+ let providerId :string | undefined = settings . defaultConfigurationProvider ;
944969if ( this . configurationJson ) {
970+ if ( ! providerId ) {
971+ providerId = this . configurationJson . configurations [ 0 ] . configurationProvider ;
972+ }
945973this . resetToDefaultSettings ( true ) ;
946974}
947975this . applyDefaultIncludePathsAndFrameworks ( ) ;
948- const settings :CppSettings = new CppSettings ( this . rootUri ) ;
949- if ( settings . defaultConfigurationProvider ) {
976+ if ( providerId ) {
950977if ( this . configurationJson ) {
951- this . configurationJson . configurations . forEach ( config => {
952- config . configurationProvider = settings . defaultConfigurationProvider ?settings . defaultConfigurationProvider :undefined ;
953- } ) ;
978+ this . configurationJson . configurations [ 0 ] . configurationProvider = providerId ;
954979}
955- settings . update ( "default.configurationProvider" , undefined ) ; // delete the setting
956980}
957981
958982await util . writeFileText ( fullPathToFile , jsonc . stringify ( this . configurationJson , null , 4 ) ) ;