@@ -405,12 +405,8 @@ function registerProgressHandlers(client: lsp.LanguageClient) {
405405 * @param configName
406406 * @param bundled
407407 */
408- function getProbeLocations ( configValue : string | null , bundled : string ) : string [ ] {
408+ function getProbeLocations ( bundled : string ) : string [ ] {
409409 const locations = [ ] ;
410- // Always use config value if it's specified
411- if ( configValue ) {
412- locations . push ( configValue ) ;
413- }
414410 // Prioritize the bundled version
415411 locations . push ( bundled ) ;
416412 // Look in workspaces currently open
@@ -425,7 +421,7 @@ function getProbeLocations(configValue: string|null, bundled: string): string[]
425421 * Construct the arguments that's used to spawn the server process.
426422 * @param ctx vscode extension context
427423 */
428- function constructArgs ( ctx : vscode . ExtensionContext ) : string [ ] {
424+ function constructArgs ( ctx : vscode . ExtensionContext , viewEngine : boolean ) : string [ ] {
429425 const config = vscode . workspace . getConfiguration ( ) ;
430426 const args : string [ ] = [ '--logToConsole' ] ;
431427
@@ -437,15 +433,15 @@ function constructArgs(ctx: vscode.ExtensionContext): string[] {
437433 args . push ( '--logVerbosity' , ngLog ) ;
438434 }
439435
440- const ngProbeLocations = getProbeLocations ( null , ctx . extensionPath ) ;
441- args . push ( '--ngProbeLocations' , ngProbeLocations . join ( ',' ) ) ;
442-
443- // Because the configuration is typed as "boolean" in package.json, vscode
444- // will return false even when the value is not set. If value is false, then
445- // we need to check if all projects support Ivy language service.
446- const viewEngine : boolean = config . get ( 'angular.view-engine' ) || ! allProjectsSupportIvy ( ) ;
436+ const ngProbeLocations = getProbeLocations ( ctx . extensionPath ) ;
447437 if ( viewEngine ) {
448438 args . push ( '--viewEngine' ) ;
439+ args . push ( '--ngProbeLocations' , [
440+ path . join ( ctx . extensionPath , 'v12_language_service' ) ,
441+ ...ngProbeLocations ,
442+ ] . join ( ',' ) ) ;
443+ } else {
444+ args . push ( '--ngProbeLocations' , ngProbeLocations . join ( ',' ) ) ;
449445 }
450446
451447 const includeAutomaticOptionalChainCompletions =
@@ -461,7 +457,7 @@ function constructArgs(ctx: vscode.ExtensionContext): string[] {
461457 }
462458
463459 const tsdk : string | null = config . get ( 'typescript.tsdk' , null ) ;
464- const tsProbeLocations = getProbeLocations ( tsdk , ctx . extensionPath ) ;
460+ const tsProbeLocations = [ tsdk , ... getProbeLocations ( ctx . extensionPath ) ] ;
465461 args . push ( '--tsProbeLocations' , tsProbeLocations . join ( ',' ) ) ;
466462
467463 return args ;
@@ -475,9 +471,22 @@ function getServerOptions(ctx: vscode.ExtensionContext, debug: boolean): lsp.Nod
475471 NG_DEBUG : true ,
476472 } ;
477473
474+ // Because the configuration is typed as "boolean" in package.json, vscode
475+ // will return false even when the value is not set. If value is false, then
476+ // we need to check if all projects support Ivy language service.
477+ const config = vscode . workspace . getConfiguration ( ) ;
478+ const viewEngine : boolean = config . get ( 'angular.view-engine' ) || ! allProjectsSupportIvy ( ) ;
479+
478480 // Node module for the language server
481+ const args = constructArgs ( ctx , viewEngine ) ;
479482 const prodBundle = ctx . asAbsolutePath ( 'server' ) ;
480483 const devBundle = ctx . asAbsolutePath ( path . join ( 'dist' , 'server' , 'server.js' ) ) ;
484+ // VS Code Insider launches extensions in debug mode by default but users
485+ // install prod bundle so we have to check whether dev bundle exists.
486+ const latestServerModule = debug && fs . existsSync ( devBundle ) ? devBundle : prodBundle ;
487+ const v12ServerModule = ctx . asAbsolutePath (
488+ path . join ( 'v12_language_service' , 'node_modules' , '@angular' , 'language-server' ) ) ;
489+ const module = viewEngine ? v12ServerModule : latestServerModule ;
481490
482491 // Argv options for Node.js
483492 const prodExecArgv : string [ ] = [ ] ;
@@ -489,11 +498,9 @@ function getServerOptions(ctx: vscode.ExtensionContext, debug: boolean): lsp.Nod
489498 ] ;
490499
491500 return {
492- // VS Code Insider launches extensions in debug mode by default but users
493- // install prod bundle so we have to check whether dev bundle exists.
494- module : debug && fs . existsSync ( devBundle ) ? devBundle : prodBundle ,
501+ module,
495502 transport : lsp . TransportKind . ipc ,
496- args : constructArgs ( ctx ) ,
503+ args,
497504 options : {
498505 env : debug ? devEnv : prodEnv ,
499506 execArgv : debug ? devExecArgv : prodExecArgv ,
@@ -514,4 +521,4 @@ function allProjectsSupportIvy() {
514521 }
515522 }
516523 return true ;
517- }
524+ }
0 commit comments