@@ -29,47 +29,69 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc
2929 ) {
3030 super ( workspaceService , documentManager , platformService , configurationService ) ;
3131 }
32+
3233 public async resolveDebugConfiguration (
3334 folder : WorkspaceFolder | undefined ,
3435 debugConfiguration : LaunchRequestArguments ,
3536 _token ?: CancellationToken
3637 ) : Promise < LaunchRequestArguments | undefined > {
37- const workspaceFolder = this . getWorkspaceFolder ( folder ) ;
38-
39- const config = debugConfiguration as LaunchRequestArguments ;
40- const numberOfSettings = Object . keys ( config ) ;
41-
42- if ( ( config . noDebug === true && numberOfSettings . length === 1 ) || numberOfSettings . length === 0 ) {
38+ if (
39+ debugConfiguration . name === undefined &&
40+ debugConfiguration . type === undefined &&
41+ debugConfiguration . request === undefined &&
42+ debugConfiguration . program === undefined &&
43+ debugConfiguration . env === undefined
44+ ) {
4345 const defaultProgram = this . getProgram ( ) ;
44-
45- config . name = 'Launch' ;
46- config . type = DebuggerTypeName ;
47- config . request = 'launch' ;
48- config . program = defaultProgram ? defaultProgram : '' ;
49- config . env = { } ;
46+ debugConfiguration . name = 'Launch' ;
47+ debugConfiguration . type = DebuggerTypeName ;
48+ debugConfiguration . request = 'launch' ;
49+ debugConfiguration . program = defaultProgram ?? '' ;
50+ debugConfiguration . env = { } ;
5051 }
5152
52- await this . provideLaunchDefaults ( workspaceFolder , config ) ;
53+ const workspaceFolder = this . getWorkspaceFolder ( folder ) ;
54+ this . resolveAndUpdatePaths ( workspaceFolder , debugConfiguration ) ;
55+ return debugConfiguration ;
56+ }
5357
54- const isValid = await this . validateLaunchConfiguration ( folder , config ) ;
58+ public async resolveDebugConfigurationWithSubstitutedVariables (
59+ folder : WorkspaceFolder | undefined ,
60+ debugConfiguration : LaunchRequestArguments ,
61+ _token ?: CancellationToken
62+ ) : Promise < LaunchRequestArguments | undefined > {
63+ const workspaceFolder = this . getWorkspaceFolder ( folder ) ;
64+ await this . provideLaunchDefaults ( workspaceFolder , debugConfiguration ) ;
65+
66+ const isValid = await this . validateLaunchConfiguration ( folder , debugConfiguration ) ;
5567 if ( ! isValid ) {
5668 return ;
5769 }
5870
59- const dbgConfig = debugConfiguration ;
60- if ( Array . isArray ( dbgConfig . debugOptions ) ) {
61- dbgConfig . debugOptions = dbgConfig . debugOptions ! . filter (
62- ( item , pos ) => dbgConfig . debugOptions ! . indexOf ( item ) === pos
71+ if ( Array . isArray ( debugConfiguration . debugOptions ) ) {
72+ debugConfiguration . debugOptions = debugConfiguration . debugOptions ! . filter (
73+ ( item , pos ) => debugConfiguration . debugOptions ! . indexOf ( item ) === pos
6374 ) ;
6475 }
6576 return debugConfiguration ;
6677 }
78+
6779 // tslint:disable-next-line:cyclomatic-complexity
6880 protected async provideLaunchDefaults (
6981 workspaceFolder : Uri | undefined ,
7082 debugConfiguration : LaunchRequestArguments
7183 ) : Promise < void > {
72- this . resolveAndUpdatePaths ( workspaceFolder , debugConfiguration ) ;
84+ if ( debugConfiguration . python === undefined ) {
85+ debugConfiguration . python = debugConfiguration . pythonPath ;
86+ }
87+ if ( debugConfiguration . debugAdapterPython === undefined ) {
88+ debugConfiguration . debugAdapterPython = debugConfiguration . pythonPath ;
89+ }
90+ if ( debugConfiguration . debugLauncherPython === undefined ) {
91+ debugConfiguration . debugLauncherPython = debugConfiguration . pythonPath ;
92+ }
93+ delete debugConfiguration . pythonPath ;
94+
7395 if ( typeof debugConfiguration . cwd !== 'string' && workspaceFolder ) {
7496 debugConfiguration . cwd = workspaceFolder . fsPath ;
7597 }
@@ -160,10 +182,18 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc
160182 debugConfiguration : LaunchRequestArguments
161183 ) : Promise < boolean > {
162184 const diagnosticService = this . invalidPythonPathInDebuggerService ;
163- return diagnosticService . validatePythonPath (
164- debugConfiguration . pythonPath ,
165- this . pythonPathSource ,
166- folder ? folder . uri : undefined
185+ return (
186+ diagnosticService . validatePythonPath ( debugConfiguration . python , this . pythonPathSource , folder ?. uri ) &&
187+ diagnosticService . validatePythonPath (
188+ debugConfiguration . debugAdapterPython ,
189+ this . pythonPathSource ,
190+ folder ?. uri
191+ ) &&
192+ diagnosticService . validatePythonPath (
193+ debugConfiguration . debugLauncherPython ,
194+ this . pythonPathSource ,
195+ folder ?. uri
196+ )
167197 ) ;
168198 }
169199}
0 commit comments