Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb4e2a84

Browse files
authored
Automatically fall back to config provider (microsoft#6504)
1 parentf6d7577 commitb4e2a84

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

‎Extension/src/LanguageServer/client.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,7 @@ export class DefaultClient implements Client {
14321432
if(!rootFolder){
14331433
return;// There is no c_cpp_properties.json to edit because there is no folder open.
14341434
}
1435+
this.configuration.handleConfigurationChange();
14351436
constselectedProvider:string|undefined=this.configuration.CurrentConfigurationProvider;
14361437
if(!selectedProvider){
14371438
constask:PersistentFolderState<boolean>=newPersistentFolderState<boolean>("Client.registerProvider",true,rootFolder);

‎Extension/src/LanguageServer/configurations.ts‎

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import * as telemetry from '../telemetry';
1212
import{PersistentFolderState}from'./persistentState';
1313
import{CppSettings,OtherSettings}from'./settings';
1414
import{ABTestSettings,getABTestSettings}from'../abTesting';
15-
import{getCustomConfigProviders}from'./customProviders';
15+
import{CustomConfigurationProviderCollection,getCustomConfigProviders}from'./customProviders';
1616
import{SettingsPanel}from'./settingsPanel';
1717
import*asosfrom'os';
1818
importescapeStringRegExp= require('escape-string-regexp');
@@ -708,6 +708,27 @@ export class CppProperties {
708708

709709
configuration.browse.limitSymbolsToIncludedHeaders=this.updateConfigurationStringOrBoolean(configuration.browse.limitSymbolsToIncludedHeaders,settings.defaultLimitSymbolsToIncludedHeaders,env);
710710
configuration.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+
constproviders: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

713734
this.updateCompileCommandsFileWatchers();
@@ -898,7 +919,7 @@ export class CppProperties {
898919
}
899920
}
900921

901-
privatehandleConfigurationChange():void{
922+
publichandleConfigurationChange():void{
902923
if(this.propertiesFile===undefined){
903924
return;// Occurs when propertiesFile hasn't been checked yet.
904925
}
@@ -941,18 +962,21 @@ export class CppProperties {
941962
}
942963

943964
constfullPathToFile: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+
constsettings:CppSettings=newCppSettings(this.rootUri);
968+
letproviderId:string|undefined=settings.defaultConfigurationProvider;
944969
if(this.configurationJson){
970+
if(!providerId){
971+
providerId=this.configurationJson.configurations[0].configurationProvider;
972+
}
945973
this.resetToDefaultSettings(true);
946974
}
947975
this.applyDefaultIncludePathsAndFrameworks();
948-
constsettings:CppSettings=newCppSettings(this.rootUri);
949-
if(settings.defaultConfigurationProvider){
976+
if(providerId){
950977
if(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

958982
awaitutil.writeFileText(fullPathToFile,jsonc.stringify(this.configurationJson,null,4));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp