@@ -767,9 +767,9 @@ export class CppProperties {
767767 const compilerPathEnd : number = compilerPathStart === - 1 ? - 1 : curText . indexOf ( '"' , curText . indexOf ( '"' , curText . indexOf ( ":" , compilerPathStart ) ) + 1 ) + 1 ;
768768
769769 if ( this . prevSquiggleMetrics [ this . CurrentConfiguration . name ] === undefined ) {
770- this . prevSquiggleMetrics [ this . CurrentConfiguration . name ] = { PathNonExistent : 0 , PathNotAFile : 0 , PathNotADirectory : 0 } ;
770+ this . prevSquiggleMetrics [ this . CurrentConfiguration . name ] = { PathNonExistent : 0 , PathNotAFile : 0 , PathNotADirectory : 0 , CompilerPathMissingQuotes : 0 } ;
771771 }
772- let newSquiggleMetrics : { [ key : string ] : number } = { PathNonExistent : 0 , PathNotAFile : 0 , PathNotADirectory : 0 } ;
772+ let newSquiggleMetrics : { [ key : string ] : number } = { PathNonExistent : 0 , PathNotAFile : 0 , PathNotADirectory : 0 , CompilerPathMissingQuotes : 0 } ;
773773 const isWindows : boolean = os . platform ( ) === 'win32' ;
774774
775775 for ( let curPath of paths ) {
@@ -809,11 +809,15 @@ export class CppProperties {
809809 }
810810 }
811811
812+ let compilerPathNeedsQuotes : boolean = false ;
812813 if ( isCompilerPath ) {
814+ resolvedPath = resolvedPath . trim ( ) ;
813815 let compilerPathAndArgs : util . CompilerPathAndArgs = util . extractCompilerPathAndArgs ( resolvedPath ) ;
814816 if ( isWindows && compilerPathAndArgs . compilerPath . endsWith ( "cl.exe" ) ) {
815817 continue ; // Don't squiggle invalid cl.exe paths because it could be for an older preview build.
816818 }
819+ // Squiggle when the compiler's path has spaces without quotes but args are used.
820+ compilerPathNeedsQuotes = compilerPathAndArgs . additionalArgs && ! resolvedPath . startsWith ( '"' ) && compilerPathAndArgs . compilerPath . includes ( " " ) ;
817821 resolvedPath = compilerPathAndArgs . compilerPath ;
818822 curPath = curPath . replace ( / \" / g, `\\"` ) ;
819823 }
@@ -858,11 +862,16 @@ export class CppProperties {
858862 if ( ( curOffset >= forcedIncludeStart && curOffset <= forcedeIncludeEnd ) ||
859863 ( curOffset >= compileCommandsStart && curOffset <= compileCommandsEnd ) ||
860864 ( curOffset >= compilerPathStart && curOffset <= compilerPathEnd ) ) {
861- if ( util . checkFileExistsSync ( resolvedPath ) ) {
862- continue ;
865+ if ( compilerPathNeedsQuotes ) {
866+ message = `Compiler path with spaces and arguments is missing \\" around the path.` ;
867+ newSquiggleMetrics . CompilerPathMissingQuotes ++ ;
868+ } else {
869+ if ( util . checkFileExistsSync ( resolvedPath ) ) {
870+ continue ;
871+ }
872+ message = `Path is not a file: "${ resolvedPath } ".` ;
873+ newSquiggleMetrics . PathNotAFile ++ ;
863874 }
864- message = `Path is not a file: "${ resolvedPath } ".` ;
865- newSquiggleMetrics . PathNotAFile ++ ;
866875 } else {
867876 if ( util . checkDirectoryExistsSync ( resolvedPath ) ) {
868877 continue ;
@@ -895,6 +904,9 @@ export class CppProperties {
895904 if ( newSquiggleMetrics . PathNotADirectory !== this . prevSquiggleMetrics [ this . CurrentConfiguration . name ] . PathNotADirectory ) {
896905 changedSquiggleMetrics . PathNotADirectory = newSquiggleMetrics . PathNotADirectory ;
897906 }
907+ if ( newSquiggleMetrics . CompilerPathMissingQuotes !== this . prevSquiggleMetrics [ this . CurrentConfiguration . name ] . CompilerPathMissingQuotes ) {
908+ changedSquiggleMetrics . CompilerPathMissingQuotes = newSquiggleMetrics . CompilerPathMissingQuotes ;
909+ }
898910 if ( Object . keys ( changedSquiggleMetrics ) . length > 0 ) {
899911 telemetry . logLanguageServerEvent ( "ConfigSquiggles" , null , changedSquiggleMetrics ) ;
900912 }
0 commit comments