File tree Expand file tree Collapse file tree 2 files changed +14
-14
lines changed
Extension/src/LanguageServer Expand file tree Collapse file tree 2 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -920,21 +920,13 @@ export class DefaultClient implements Client {
920
920
921
921
const items : IndexableQuickPickItem [ ] = [ ] ;
922
922
for ( let i : number = 0 ; i < paths . length ; i ++ ) {
923
- let option : string | undefined ;
924
- let isCompiler : boolean = false ;
925
- const slash : string = ( os . platform ( ) === 'win32' ) ? "\\" : "/" ;
923
+ const compilerName : string = path . basename ( paths [ i ] ) ;
924
+ const isCompiler : boolean = compilerName !== paths [ i ] ;
926
925
927
- if ( paths [ i ] . includes ( slash ) ) {
928
- if ( paths [ i ] . split ( slash ) . pop ( ) !== undefined ) {
929
- option = paths [ i ] . split ( slash ) . pop ( ) ;
930
- isCompiler = true ;
931
- }
932
- }
933
-
934
- if ( option !== undefined && isCompiler ) {
935
- const path : string | undefined = paths [ i ] . replace ( option , "" ) ;
926
+ if ( isCompiler ) {
927
+ const path : string | undefined = paths [ i ] . replace ( compilerName , "" ) ;
936
928
const description : string = localize ( "found.string" , "Found at {0}" , path ) ;
937
- items . push ( { label : option , description : description , index : i } ) ;
929
+ items . push ( { label : compilerName , description : description , index : i } ) ;
938
930
} else {
939
931
items . push ( { label : paths [ i ] , index : i } ) ;
940
932
}
Original file line number Diff line number Diff line change @@ -396,7 +396,15 @@ export class CppProperties {
396
396
( isUnset ( settings . defaultCompileCommands ) || settings . defaultCompileCommands === "" ) && ! configuration . compileCommands ) {
397
397
// compile_commands.json already specifies a compiler. compilerPath overrides the compile_commands.json compiler so
398
398
// don't set a default when compileCommands is in use.
399
- configuration . compilerPath = this . defaultCompilerPath ;
399
+
400
+ // if the compiler is a cl.exe compiler, replace the full path with the "cl.exe" string.
401
+ const compiler : string = path . basename ( this . defaultCompilerPath ) . toLowerCase ( ) ;
402
+
403
+ if ( compiler === "cl.exe" ) {
404
+ configuration . compilerPath = "cl.exe" ;
405
+ } else {
406
+ configuration . compilerPath = this . defaultCompilerPath ;
407
+ }
400
408
}
401
409
if ( ( isUnset ( settings . defaultCStandard ) || settings . defaultCStandard === "" ) && this . defaultCStandard ) {
402
410
configuration . cStandard = this . defaultCStandard ;
You can’t perform that action at this time.
0 commit comments