@@ -289,8 +289,6 @@ export class CppProperties {
289
289
}
290
290
}
291
291
} ) ;
292
-
293
- this . handleConfigurationChange ( ) ;
294
292
}
295
293
public set CompilerDefaults ( compilerDefaults : CompilerDefaults ) {
296
294
this . defaultCompilerPath = compilerDefaults . trustedCompilerFound ? compilerDefaults . compilerPath : null ;
@@ -755,7 +753,7 @@ export class CppProperties {
755
753
return result ;
756
754
}
757
755
758
- private resolveAndSplit ( paths : string [ ] | undefined , defaultValue : string [ ] | undefined , env : Environment , glob : boolean = false ) : string [ ] {
756
+ private resolveAndSplit ( paths : string [ ] | undefined , defaultValue : string [ ] | undefined , env : Environment , assumeRelative : boolean = true , glob : boolean = false ) : string [ ] {
759
757
const resolvedVariables : string [ ] = [ ] ;
760
758
if ( paths === undefined ) {
761
759
return resolvedVariables ;
@@ -767,7 +765,7 @@ export class CppProperties {
767
765
// Do not futher try to resolve a "${env:VAR}"
768
766
resolvedVariables . push ( resolvedVariable ) ;
769
767
} else {
770
- const entries : string [ ] = resolvedVariable . split ( path . delimiter ) . map ( e => glob ? this . resolvePath ( e , false ) : e ) . filter ( e => e ) ;
768
+ const entries : string [ ] = resolvedVariable . split ( path . delimiter ) . map ( e => glob ? this . resolvePath ( e , false , assumeRelative ) : e ) . filter ( e => e ) ;
771
769
resolvedVariables . push ( ...entries ) ;
772
770
}
773
771
} ) ;
@@ -838,12 +836,12 @@ export class CppProperties {
838
836
return property ;
839
837
}
840
838
841
- private updateConfigurationPathsArray ( paths : string [ ] | undefined , defaultValue : string [ ] | undefined , env : Environment ) : string [ ] | undefined {
839
+ private updateConfigurationPathsArray ( paths : string [ ] | undefined , defaultValue : string [ ] | undefined , env : Environment , assumeRelative : boolean = true ) : string [ ] | undefined {
842
840
if ( paths ) {
843
- return this . resolveAndSplit ( paths , defaultValue , env , true ) ;
841
+ return this . resolveAndSplit ( paths , defaultValue , env , assumeRelative , true ) ;
844
842
}
845
843
if ( ! paths && defaultValue ) {
846
- return this . resolveAndSplit ( defaultValue , [ ] , env , true ) ;
844
+ return this . resolveAndSplit ( defaultValue , [ ] , env , assumeRelative , true ) ;
847
845
}
848
846
return paths ;
849
847
}
@@ -934,7 +932,7 @@ export class CppProperties {
934
932
935
933
configuration . macFrameworkPath = this . updateConfigurationStringArray ( configuration . macFrameworkPath , settings . defaultMacFrameworkPath , env ) ;
936
934
configuration . windowsSdkVersion = this . updateConfigurationString ( configuration . windowsSdkVersion , settings . defaultWindowsSdkVersion , env ) ;
937
- configuration . forcedInclude = this . updateConfigurationPathsArray ( configuration . forcedInclude , settings . defaultForcedInclude , env ) ;
935
+ configuration . forcedInclude = this . updateConfigurationPathsArray ( configuration . forcedInclude , settings . defaultForcedInclude , env , false ) ;
938
936
configuration . compileCommands = this . updateConfigurationString ( configuration . compileCommands , settings . defaultCompileCommands , env ) ;
939
937
configuration . compilerArgs = this . updateConfigurationStringArray ( configuration . compilerArgs , settings . defaultCompilerArgs , env ) ;
940
938
configuration . cStandard = this . updateConfigurationString ( configuration . cStandard , settings . defaultCStandard , env ) ;
@@ -1094,7 +1092,7 @@ export class CppProperties {
1094
1092
}
1095
1093
1096
1094
if ( configuration . forcedInclude ) {
1097
- configuration . forcedInclude = configuration . forcedInclude . map ( ( path : string ) => this . resolvePath ( path ) ) ;
1095
+ configuration . forcedInclude = configuration . forcedInclude . map ( ( path : string ) => this . resolvePath ( path , true , false ) ) ;
1098
1096
}
1099
1097
1100
1098
if ( configuration . includePath ) {
@@ -1513,7 +1511,7 @@ export class CppProperties {
1513
1511
return success ;
1514
1512
}
1515
1513
1516
- private resolvePath ( input_path : string | undefined , replaceAsterisks : boolean = true ) : string {
1514
+ private resolvePath ( input_path : string | undefined , replaceAsterisks : boolean = true , assumeRelative : boolean = true ) : string {
1517
1515
if ( ! input_path || input_path === "${default}" ) {
1518
1516
return "" ;
1519
1517
}
@@ -1537,10 +1535,12 @@ export class CppProperties {
1537
1535
result = result . replace ( / \* / g, "" ) ;
1538
1536
}
1539
1537
1540
- // Make sure all paths result to an absolute path.
1541
- // Do not add the root path to an unresolved env variable.
1542
- if ( ! result . includes ( "env:" ) && ! path . isAbsolute ( result ) && this . rootUri ) {
1543
- result = path . join ( this . rootUri . fsPath , result ) ;
1538
+ if ( assumeRelative ) {
1539
+ // Make sure all paths result to an absolute path.
1540
+ // Do not add the root path to an unresolved env variable.
1541
+ if ( ! result . includes ( "env:" ) && ! path . isAbsolute ( result ) && this . rootUri ) {
1542
+ result = path . join ( this . rootUri . fsPath , result ) ;
1543
+ }
1544
1544
}
1545
1545
1546
1546
return result ;
@@ -1634,7 +1634,7 @@ export class CppProperties {
1634
1634
errors . browsePath = this . validatePath ( config . browse ? config . browse . path : undefined ) ;
1635
1635
1636
1636
// Validate files
1637
- errors . forcedInclude = this . validatePath ( config . forcedInclude , { isDirectory : false , skipRelativePaths : true } ) ;
1637
+ errors . forcedInclude = this . validatePath ( config . forcedInclude , { isDirectory : false , assumeRelative : false } ) ;
1638
1638
errors . compileCommands = this . validatePath ( config . compileCommands , { isDirectory : false } ) ;
1639
1639
errors . dotConfig = this . validatePath ( config . dotConfig , { isDirectory : false } ) ;
1640
1640
errors . databaseFilename = this . validatePath ( config . browse ? config . browse . databaseFilename : undefined , { isDirectory : false } ) ;
@@ -1650,7 +1650,7 @@ export class CppProperties {
1650
1650
return errors ;
1651
1651
}
1652
1652
1653
- private validatePath ( input : string | string [ ] | undefined , { isDirectory = true , skipRelativePaths = false , globPaths = false } = { } ) : string | undefined {
1653
+ private validatePath ( input : string | string [ ] | undefined , { isDirectory = true , assumeRelative = true , globPaths = false } = { } ) : string | undefined {
1654
1654
if ( ! input ) {
1655
1655
return undefined ;
1656
1656
}
@@ -1666,7 +1666,7 @@ export class CppProperties {
1666
1666
}
1667
1667
1668
1668
// Resolve and split any environment variables
1669
- paths = this . resolveAndSplit ( paths , undefined , this . ExtendedEnvironment , globPaths ) ;
1669
+ paths = this . resolveAndSplit ( paths , undefined , this . ExtendedEnvironment , assumeRelative , globPaths ) ;
1670
1670
1671
1671
for ( const p of paths ) {
1672
1672
let pathExists : boolean = true ;
@@ -1677,7 +1677,7 @@ export class CppProperties {
1677
1677
1678
1678
// Check if resolved path exists
1679
1679
if ( ! fs . existsSync ( resolvedPath ) ) {
1680
- if ( skipRelativePaths && ! path . isAbsolute ( resolvedPath ) ) {
1680
+ if ( assumeRelative && ! path . isAbsolute ( resolvedPath ) ) {
1681
1681
continue ;
1682
1682
} else if ( ! this . rootUri ) {
1683
1683
pathExists = false ;
0 commit comments