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

Commite0e7944

Browse files
authored
Don't add workspaceFolderBasename to new config files (microsoft#2552)
1 parent63e18af commite0e7944

File tree

1 file changed

+36
-33
lines changed

1 file changed

+36
-33
lines changed

‎Extension/src/LanguageServer/configurations.ts‎

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { ABTestSettings, getABTestSettings } from '../abTesting';
1515
import{getCustomConfigProviders}from'./customProviders';
1616
constconfigVersion:number=4;
1717

18+
typeEnvironment={[key:string]:string|string[]};
19+
1820
// No properties are set in the config since we want to apply vscode settings first (if applicable).
1921
// That code won't trigger if another value is already set.
2022
// The property defaults are moved down to applyDefaultIncludePathsAndFrameworks.
@@ -202,7 +204,6 @@ export class CppProperties {
202204

203205
privateresetToDefaultSettings(resetIndex:boolean):void{
204206
this.configurationJson=getDefaultCppProperties();
205-
this.extendConfigurationEnvironment();
206207
if(resetIndex||this.CurrentConfigurationIndex<0||
207208
this.CurrentConfigurationIndex>=this.configurationJson.configurations.length){
208209
this.currentConfigurationIndex.Value=this.getConfigIndexForPlatform(this.configurationJson);
@@ -253,12 +254,14 @@ export class CppProperties {
253254
}
254255
}
255256

256-
privateextendConfigurationEnvironment():void{
257-
if(!this.configurationJson.env){
258-
this.configurationJson.env={};
257+
privategetExtendedEnvironment():Environment{
258+
letresult:Environment={};
259+
if(this.configurationJson.env){
260+
Object.assign(result,this.configurationJson.env);
259261
}
260262

261-
this.configurationJson.env["workspaceFolderBasename"]=path.basename(this.rootUri.fsPath);
263+
result["workspaceFolderBasename"]=path.basename(this.rootUri.fsPath);
264+
returnresult;
262265
}
263266

264267
privateasyncbuildVcpkgIncludePath():Promise<void>{
@@ -402,62 +405,63 @@ export class CppProperties {
402405
returnresult;
403406
}
404407

405-
privateresolveAndSplit(paths:string[]|undefined,defaultValue:string[]):string[]{
408+
privateresolveAndSplit(paths:string[]|undefined,defaultValue:string[],env:Environment):string[]{
406409
letresult:string[]=[];
407410
if(paths){
408411
paths.forEach(entry=>{
409-
letentries:string[]=util.resolveVariables(entry,this.configurationJson.env).split(";").filter(e=>e);
412+
letentries:string[]=util.resolveVariables(entry,env).split(";").filter(e=>e);
410413
entries=this.resolveDefaults(entries,defaultValue);
411414
result=result.concat(entries);
412415
});
413416
}
414417
returnresult;
415418
}
416419

417-
privateresolveVariables(input:string|boolean,defaultValue:string|boolean):string|boolean{
420+
privateresolveVariables(input:string|boolean,defaultValue:string|boolean,env:Environment):string|boolean{
418421
if(input===undefined||input==="${default}"){
419422
input=defaultValue;
420423
}
421424
if(typeofinput==="boolean"){
422425
returninput;
423426
}
424-
returnutil.resolveVariables(input,this.configurationJson.env);
427+
returnutil.resolveVariables(input,env);
425428
}
426429

427-
privateupdateConfiguration(property:string[],defaultValue:string[]):string[];
428-
privateupdateConfiguration(property:string,defaultValue:string):string;
429-
privateupdateConfiguration(property:string|boolean,defaultValue:boolean):boolean;
430-
privateupdateConfiguration(property,defaultValue):any{
430+
privateupdateConfiguration(property:string[],defaultValue:string[],env:Environment):string[];
431+
privateupdateConfiguration(property:string,defaultValue:string,env:Environment):string;
432+
privateupdateConfiguration(property:string|boolean,defaultValue:boolean,env:Environment):boolean;
433+
privateupdateConfiguration(property,defaultValue,env):any{
431434
if(typeofproperty==="string"||typeofdefaultValue==="string"){
432-
returnthis.resolveVariables(property,defaultValue);
435+
returnthis.resolveVariables(property,defaultValue,env);
433436
}elseif(typeofproperty==="boolean"||typeofdefaultValue==="boolean"){
434-
returnthis.resolveVariables(property,defaultValue);
437+
returnthis.resolveVariables(property,defaultValue,env);
435438
}elseif(propertyinstanceofArray||defaultValueinstanceofArray){
436439
if(property){
437-
returnthis.resolveAndSplit(property,defaultValue);
440+
returnthis.resolveAndSplit(property,defaultValue,env);
438441
}elseif(property===undefined&&defaultValue){
439-
returnthis.resolveAndSplit(defaultValue,[]);
442+
returnthis.resolveAndSplit(defaultValue,[],env);
440443
}
441444
}
442445
returnproperty;
443446
}
444447

445448
privateupdateServerOnFolderSettingsChange():void{
446449
letsettings:CppSettings=newCppSettings(this.rootUri);
450+
letenv:Environment=this.ExtendedEnvironment;
447451
for(leti:number=0;i<this.configurationJson.configurations.length;i++){
448452
letconfiguration:Configuration=this.configurationJson.configurations[i];
449453

450-
configuration.includePath=this.updateConfiguration(configuration.includePath,settings.defaultIncludePath);
451-
configuration.defines=this.updateConfiguration(configuration.defines,settings.defaultDefines);
452-
configuration.macFrameworkPath=this.updateConfiguration(configuration.macFrameworkPath,settings.defaultMacFrameworkPath);
453-
configuration.windowsSdkVersion=this.updateConfiguration(configuration.windowsSdkVersion,settings.defaultWindowsSdkVersion);
454-
configuration.forcedInclude=this.updateConfiguration(configuration.forcedInclude,settings.defaultForcedInclude);
455-
configuration.compileCommands=this.updateConfiguration(configuration.compileCommands,settings.defaultCompileCommands);
456-
configuration.compilerPath=this.updateConfiguration(configuration.compilerPath,settings.defaultCompilerPath);
457-
configuration.cStandard=this.updateConfiguration(configuration.cStandard,settings.defaultCStandard);
458-
configuration.cppStandard=this.updateConfiguration(configuration.cppStandard,settings.defaultCppStandard);
459-
configuration.intelliSenseMode=this.updateConfiguration(configuration.intelliSenseMode,settings.defaultIntelliSenseMode);
460-
configuration.configurationProvider=this.updateConfiguration(configuration.configurationProvider,settings.defaultConfigurationProvider);
454+
configuration.includePath=this.updateConfiguration(configuration.includePath,settings.defaultIncludePath,env);
455+
configuration.defines=this.updateConfiguration(configuration.defines,settings.defaultDefines,env);
456+
configuration.macFrameworkPath=this.updateConfiguration(configuration.macFrameworkPath,settings.defaultMacFrameworkPath,env);
457+
configuration.windowsSdkVersion=this.updateConfiguration(configuration.windowsSdkVersion,settings.defaultWindowsSdkVersion,env);
458+
configuration.forcedInclude=this.updateConfiguration(configuration.forcedInclude,settings.defaultForcedInclude,env);
459+
configuration.compileCommands=this.updateConfiguration(configuration.compileCommands,settings.defaultCompileCommands,env);
460+
configuration.compilerPath=this.updateConfiguration(configuration.compilerPath,settings.defaultCompilerPath,env);
461+
configuration.cStandard=this.updateConfiguration(configuration.cStandard,settings.defaultCStandard,env);
462+
configuration.cppStandard=this.updateConfiguration(configuration.cppStandard,settings.defaultCppStandard,env);
463+
configuration.intelliSenseMode=this.updateConfiguration(configuration.intelliSenseMode,settings.defaultIntelliSenseMode,env);
464+
configuration.configurationProvider=this.updateConfiguration(configuration.configurationProvider,settings.defaultConfigurationProvider,env);
461465

462466
if(!configuration.browse){
463467
configuration.browse={};
@@ -476,11 +480,11 @@ export class CppProperties {
476480
}
477481
}
478482
}else{
479-
configuration.browse.path=this.updateConfiguration(configuration.browse.path,settings.defaultBrowsePath);
483+
configuration.browse.path=this.updateConfiguration(configuration.browse.path,settings.defaultBrowsePath,env);
480484
}
481485

482-
configuration.browse.limitSymbolsToIncludedHeaders=this.updateConfiguration(configuration.browse.limitSymbolsToIncludedHeaders,settings.defaultLimitSymbolsToIncludedHeaders);
483-
configuration.browse.databaseFilename=this.updateConfiguration(configuration.browse.databaseFilename,settings.defaultDatabaseFilename);
486+
configuration.browse.limitSymbolsToIncludedHeaders=this.updateConfiguration(configuration.browse.limitSymbolsToIncludedHeaders,settings.defaultLimitSymbolsToIncludedHeaders,env);
487+
configuration.browse.databaseFilename=this.updateConfiguration(configuration.browse.databaseFilename,settings.defaultDatabaseFilename,env);
484488
}
485489

486490
this.updateCompileCommandsFileWatchers();
@@ -619,11 +623,10 @@ export class CppProperties {
619623
if(this.configurationJson.env){
620624
deletethis.configurationJson.env['workspaceRoot'];
621625
deletethis.configurationJson.env['workspaceFolder'];
626+
deletethis.configurationJson.env['workspaceFolderBasename'];
622627
deletethis.configurationJson.env['default'];
623628
}
624629

625-
this.extendConfigurationEnvironment();
626-
627630
// Warning: There is a chance that this is incorrect in the event that the c_cpp_properties.json file was created before
628631
// the system includes were available.
629632
this.configurationIncomplete=false;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp