@@ -15,7 +15,7 @@ import { isDefined } from 'vscode-common/out/types';
1515
1616export class StarlarkDebugger
1717 extends LaunchableComponent < StarlarkDebuggerConfiguration >
18- implements vscode . Disposable , vscode . DebugAdapterDescriptorFactory , vscode . DebugConfigurationProvider {
18+ implements vscode . DebugAdapterDescriptorFactory , vscode . DebugConfigurationProvider {
1919
2020 constructor (
2121 public readonly settings : StarlarkDebuggerSettings ,
@@ -171,31 +171,41 @@ export class StarlarkDebugger
171171 * @return The resolved debug configuration or undefined or null.
172172 */
173173 async resolveDebugConfigurationWithSubstitutedVariables ( folder : vscode . WorkspaceFolder | undefined , config : vscode . DebugConfiguration , token ?: vscode . CancellationToken ) : Promise < vscode . DebugConfiguration | undefined > {
174- let targetLabel = config . targetLabel ;
175- if ( ! targetLabel ) {
176- targetLabel = await this . handleCommandAskForDebugTargetLabel ( ) ;
177- }
178- if ( ! targetLabel ) {
179- vscode . window . showInformationMessage ( 'A label for the "bazel build" command is required. Please add it to your launch configuration.' ) ;
180- return ;
174+ if ( config . request !== 'launch' ) {
175+ return config
181176 }
182177
178+ //
183179 // launch the debug adapter if it not already running
180+ //
181+
184182 if ( this . status !== Status . READY && this . status !== Status . DISABLED ) {
185183 // this needs to wait until the thing is actually running!
186184 await this . handleCommandLaunch ( ) ;
187185 this . restart ( ) ;
188186 }
189187
190- // launch the bazel debugger if this is a launch config
191- if ( config . request === 'launch' ) {
192- const bazelSettings = await this . bazelSettings . get ( ) ;
193- const flags = bazelSettings . starlarkDebugFlags || [ ] ;
194- const extraFlags = config . extraBazelFlags || [ ] ;
188+ //
189+ // make sure target label is defined
190+ //
195191
196- await vscode . commands . executeCommand ( CommandName . Invoke ,
197- [ 'build' , targetLabel , ... flags , ... extraFlags ] . filter ( arg => isDefined ( arg ) ) ) ;
192+ if ( ! config . targetLabel ) {
193+ config . targetLabel = await this . handleCommandAskForDebugTargetLabel ( ) ;
198194 }
195+ if ( ! config . targetLabel ) {
196+ vscode . window . showInformationMessage ( 'A label for the "bazel build" command is required. Please add it to your launch configuration.' ) ;
197+ return ;
198+ }
199+
200+ //
201+ // run bazel debug
202+ //
203+ const bazelSettings = await this . bazelSettings . get ( ) ;
204+ const flags = bazelSettings . starlarkDebugFlags || [ ] ;
205+ const extraFlags = config . extraBazelFlags || [ ] ;
206+
207+ await vscode . commands . executeCommand ( CommandName . Invoke ,
208+ [ 'build' , config . targetLabel , ...flags , ...extraFlags ] . filter ( arg => isDefined ( arg ) ) ) ;
199209
200210 return config ;
201211 }
0 commit comments