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

Commit775aba8

Browse files
shankaryoga21bobbrow
authored andcommitted
don't use falsy comparisons when resolving default settings. (microsoft#2592)
1 parentb3fb255 commit775aba8

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

‎Extension/src/LanguageServer/configurations.ts‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -215,39 +215,43 @@ export class CppProperties {
215215
if(this.configurationIncomplete&&this.defaultIncludes&&this.defaultFrameworks&&this.vcpkgPathReady){
216216
letconfiguration:Configuration=this.CurrentConfiguration;
217217
letsettings:CppSettings=newCppSettings(this.rootUri);
218+
letisUnset:(input:any)=>boolean=(input:any)=>{
219+
// default values for "default" config settings is null.
220+
returninput===null;
221+
};
218222

219223
// Anything that has a vscode setting for it will be resolved in updateServerOnFolderSettingsChange.
220224
// So if a property is currently unset, but has a vscode setting, don't set it yet, otherwise the linkage
221225
// to the setting will be lost if this configuration is saved into a c_cpp_properties.json file.
222226

223227
// Only add settings from the default compiler if user hasn't explicitly set the corresponding VS Code setting.
224228

225-
if(!settings.defaultIncludePath){
229+
if(isUnset(settings.defaultIncludePath)){
226230
// We don't add system includes to the includePath anymore. The language server has this information.
227231
letabTestSettings:ABTestSettings=getABTestSettings();
228232
letrootFolder:string=abTestSettings.UseRecursiveIncludes ?"${workspaceFolder}/**" :"${workspaceFolder}";
229233
configuration.includePath=[rootFolder].concat(this.vcpkgIncludes);
230234
}
231235
// browse.path is not set by default anymore. When it is not set, the includePath will be used instead.
232-
if(!settings.defaultDefines){
236+
if(isUnset(settings.defaultDefines)){
233237
configuration.defines=(process.platform==='win32') ?["_DEBUG","UNICODE","_UNICODE"] :[];
234238
}
235-
if(!settings.defaultMacFrameworkPath&&process.platform==='darwin'){
239+
if(isUnset(settings.defaultMacFrameworkPath)&&process.platform==='darwin'){
236240
configuration.macFrameworkPath=this.defaultFrameworks;
237241
}
238-
if(!settings.defaultWindowsSdkVersion&&this.defaultWindowsSdkVersion&&process.platform==='win32'){
242+
if(isUnset(settings.defaultWindowsSdkVersion)&&this.defaultWindowsSdkVersion&&process.platform==='win32'){
239243
configuration.windowsSdkVersion=this.defaultWindowsSdkVersion;
240244
}
241-
if(!settings.defaultCompilerPath&&this.defaultCompilerPath){
245+
if(isUnset(settings.defaultCompilerPath)&&this.defaultCompilerPath){
242246
configuration.compilerPath=this.defaultCompilerPath;
243247
}
244-
if(!settings.defaultCStandard&&this.defaultCStandard){
248+
if(isUnset(settings.defaultCStandard)&&this.defaultCStandard){
245249
configuration.cStandard=this.defaultCStandard;
246250
}
247-
if(!settings.defaultCppStandard&&this.defaultCppStandard){
251+
if(isUnset(settings.defaultCppStandard)&&this.defaultCppStandard){
248252
configuration.cppStandard=this.defaultCppStandard;
249253
}
250-
if(!settings.defaultIntelliSenseMode){
254+
if(isUnset(settings.defaultIntelliSenseMode)){
251255
configuration.intelliSenseMode=this.defaultIntelliSenseMode;
252256
}
253257
this.configurationIncomplete=false;
@@ -431,11 +435,11 @@ export class CppProperties {
431435
privateupdateConfiguration(property:string,defaultValue:string,env:Environment):string;
432436
privateupdateConfiguration(property:string|boolean,defaultValue:boolean,env:Environment):boolean;
433437
privateupdateConfiguration(property,defaultValue,env):any{
434-
if(typeofproperty==="string"||typeofdefaultValue==="string"){
438+
if(util.isString(property)||util.isString(defaultValue)){
435439
returnthis.resolveVariables(property,defaultValue,env);
436-
}elseif(typeofproperty==="boolean"||typeofdefaultValue==="boolean"){
440+
}elseif(util.isBoolean(property)||util.isBoolean(defaultValue)){
437441
returnthis.resolveVariables(property,defaultValue,env);
438-
}elseif(propertyinstanceofArray||defaultValueinstanceofArray){
442+
}elseif(util.isArrayOfString(property)||util.isArrayOfString(defaultValue)){
439443
if(property){
440444
returnthis.resolveAndSplit(property,defaultValue,env);
441445
}elseif(property===undefined&&defaultValue){

‎Extension/src/common.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,20 @@ export function isNumber(input: any): input is number {
183183
returntypeof(input)==="number";
184184
}
185185

186+
exportfunctionisBoolean(input:any):input isboolean{
187+
returntypeof(input)==="boolean";
188+
}
189+
190+
exportfunctionisArray(input:any):input isany[]{
191+
returninputinstanceofArray;
192+
}
193+
186194
exportfunctionisOptionalString(input:any):input isstring|undefined{
187195
returninput===undefined||isString(input);
188196
}
189197

190198
exportfunctionisArrayOfString(input:any):input isstring[]{
191-
return(inputinstanceofArray)&&input.every(item=>isString(item));
199+
returnisArray(input)&&input.every(item=>isString(item));
192200
}
193201

194202
exportfunctionisOptionalArrayOfString(input:any):input isstring[]|undefined{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp