@@ -3,6 +3,10 @@ import * as util from "util";
33import * as vscode from "vscode" ;
44import * as child_process from "child_process" ;
55import * as fs from "node:fs/promises" ;
6+ import {
7+ showErrorWithConfigureButton ,
8+ showLLDBDapNotFoundMessage ,
9+ } from "./ui/error-messages" ;
610
711const exec = util . promisify ( child_process . execFile ) ;
812
@@ -91,12 +95,27 @@ async function getDAPExecutable(
9195 return undefined ;
9296}
9397
94- function getDAPArguments (
98+ async function getDAPArguments (
9599 folder : vscode . WorkspaceFolder | undefined ,
96100 configuration : vscode . DebugConfiguration ,
97- ) : string [ ] {
101+ userInteractive ?: boolean ,
102+ ) : Promise < string [ ] | null | undefined > {
98103 // Check the debug configuration for arguments first
99104 const debugConfigArgs = configuration . debugAdapterArgs ;
105+ if ( debugConfigArgs ) {
106+ if (
107+ ! Array . isArray ( debugConfigArgs ) ||
108+ debugConfigArgs . findIndex ( ( entry ) => typeof entry !== "string" ) !== - 1
109+ ) {
110+ if ( ! userInteractive ) {
111+ return undefined ;
112+ }
113+ return showErrorWithConfigureButton (
114+ "The debugAdapterArgs property must be an array of string values." ,
115+ ) ;
116+ }
117+ return debugConfigArgs ;
118+ }
100119 if (
101120 Array . isArray ( debugConfigArgs ) &&
102121 debugConfigArgs . findIndex ( ( entry ) => typeof entry !== "string" ) === - 1
@@ -109,29 +128,6 @@ function getDAPArguments(
109128 . get < string [ ] > ( "arguments" , [ ] ) ;
110129}
111130
112- /**
113- * Shows a modal when the debug adapter's path is not found
114- */
115- async function showLLDBDapNotFoundMessage ( path ?: string ) {
116- const message =
117- path !== undefined
118- ? `Debug adapter path: ${ path } is not a valid file`
119- : "Unable to find the path to the LLDB debug adapter executable." ;
120- const openSettingsAction = "Open Settings" ;
121- const callbackValue = await vscode . window . showErrorMessage (
122- message ,
123- { modal : true } ,
124- openSettingsAction ,
125- ) ;
126-
127- if ( openSettingsAction === callbackValue ) {
128- vscode . commands . executeCommand (
129- "workbench.action.openSettings" ,
130- "lldb-dap.executable-path" ,
131- ) ;
132- }
133- }
134-
135131/**
136132 * Creates a new {@link vscode.DebugAdapterExecutable} based on the provided workspace folder and
137133 * debug configuration. Assumes that the given debug configuration is for a local launch of lldb-dap.
@@ -176,7 +172,10 @@ export async function createDebugAdapterExecutable(
176172 ...env ,
177173 } ,
178174 } ;
179- const dbgArgs = getDAPArguments ( folder , configuration ) ;
175+ const dbgArgs = await getDAPArguments ( folder , configuration , userInteractive ) ;
176+ if ( ! dbgArgs ) {
177+ return undefined ;
178+ }
180179
181180 return new vscode . DebugAdapterExecutable ( dapPath , dbgArgs , dbgOptions ) ;
182181}
0 commit comments