@@ -18,11 +18,11 @@ const configVersion: number = 4;
1818// The property defaults are moved down to applyDefaultIncludePathsAndFrameworks.
1919function getDefaultConfig ( ) : Configuration {
2020 if ( process . platform === 'darwin' ) {
21- return { name : "Mac" , browse : { } } ;
21+ return { name : "Mac" } ;
2222 } else if ( process . platform === 'win32' ) {
23- return { name : "Win32" , browse : { } } ;
23+ return { name : "Win32" } ;
2424 } else {
25- return { name : "Linux" , browse : { } } ;
25+ return { name : "Linux" } ;
2626 }
2727}
2828
@@ -209,10 +209,7 @@ export class CppProperties {
209209 // We don't add system includes to the includePath anymore. The language server has this information.
210210 configuration . includePath = [ "${workspaceFolder}" ] . concat ( this . vcpkgIncludes ) ;
211211 }
212- if ( ! settings . defaultBrowsePath ) {
213- // We don't add system includes to the includePath anymore. The language server has this information.
214- configuration . browse . path = [ "${workspaceFolder}" ] . concat ( this . vcpkgIncludes ) ;
215- }
212+ // browse.path is not set by default anymore. When it is not set, the includePath will be used instead.
216213 if ( ! settings . defaultDefines ) {
217214 configuration . defines = ( process . platform === 'win32' ) ? [ "_DEBUG" , "UNICODE" , "_UNICODE" ] : [ ] ;
218215 }
@@ -297,15 +294,6 @@ export class CppProperties {
297294 }
298295 }
299296
300- private includePathConverted ( ) : boolean {
301- for ( let i : number = 0 ; i < this . configurationJson . configurations . length ; i ++ ) {
302- if ( this . configurationJson . configurations [ i ] . browse === undefined || this . configurationJson . configurations [ i ] . browse . path === undefined ) {
303- return false ;
304- }
305- }
306- return true ;
307- }
308-
309297 public addToIncludePathCommand ( path : string ) : void {
310298 this . handleConfigurationEditCommand ( ( document : vscode . TextDocument ) => {
311299 telemetry . logLanguageServerEvent ( "addToIncludePath" ) ;
@@ -403,7 +391,23 @@ export class CppProperties {
403391 if ( ! configuration . browse ) {
404392 configuration . browse = { } ;
405393 }
406- configuration . browse . path = this . updateConfiguration ( configuration . browse . path , settings . defaultBrowsePath ) ;
394+
395+ if ( ! configuration . browse . path ) {
396+ if ( settings . defaultBrowsePath ) {
397+ configuration . browse . path = settings . defaultBrowsePath ;
398+ } else if ( configuration . includePath ) {
399+ // If the user doesn't set browse.path, copy the includePath over. Make sure ${workspaceFolder} is in there though...
400+ configuration . browse . path = configuration . includePath . slice ( 0 ) ;
401+ if ( - 1 === configuration . includePath . findIndex ( ( value : string , index : number ) => {
402+ return ! ! value . match ( / ^ \$ \{ ( w o r k s p a c e R o o t | w o r k s p a c e F o l d e r ) \} ( \\ | \\ \* \* | \/ | \/ \* \* ) ? $ / g) ;
403+ } ) ) {
404+ configuration . browse . path . push ( "${workspaceFolder}" ) ;
405+ }
406+ }
407+ } else {
408+ configuration . browse . path = this . updateConfiguration ( configuration . browse . path , settings . defaultBrowsePath ) ;
409+ }
410+
407411 configuration . browse . limitSymbolsToIncludedHeaders = this . updateConfiguration ( configuration . browse . limitSymbolsToIncludedHeaders , settings . defaultLimitSymbolsToIncludedHeaders ) ;
408412 configuration . browse . databaseFilename = this . updateConfiguration ( configuration . browse . databaseFilename , settings . defaultDatabaseFilename ) ;
409413 }
@@ -452,7 +456,7 @@ export class CppProperties {
452456 let filePath : vscode . Uri = vscode . Uri . parse ( "untitled:" + fullPathToFile ) ;
453457 vscode . workspace . openTextDocument ( filePath ) . then ( ( document : vscode . TextDocument ) => {
454458 let edit : vscode . WorkspaceEdit = new vscode . WorkspaceEdit ( ) ;
455- if ( this . configurationJson === undefined ) {
459+ if ( this . configurationJson ) {
456460 this . resetToDefaultSettings ( true ) ;
457461 }
458462 this . applyDefaultIncludePathsAndFrameworks ( ) ;
@@ -571,17 +575,8 @@ export class CppProperties {
571575
572576 private updateToVersion2 ( ) : void {
573577 this . configurationJson . version = 2 ;
574- if ( ! this . includePathConverted ( ) ) {
575- for ( let i : number = 0 ; i < this . configurationJson . configurations . length ; i ++ ) {
576- let config : Configuration = this . configurationJson . configurations [ i ] ;
577- if ( config . browse === undefined ) {
578- config . browse = { } ;
579- }
580- if ( config . browse . path === undefined && ( this . defaultIncludes !== undefined || config . includePath !== undefined ) ) {
581- config . browse . path = ( config . includePath === undefined ) ? this . defaultIncludes . slice ( 0 ) : config . includePath . slice ( 0 ) ;
582- }
583- }
584- }
578+ // no-op. We don't automatically populate the browse.path anymore.
579+ // We use includePath if browse.path is not present which is what this code used to do.
585580 }
586581
587582 private updateToVersion3 ( ) : void {
0 commit comments