@@ -6,7 +6,14 @@ import type * as ra from "./lsp_ext";
6
6
import { Cargo } from "./toolchain" ;
7
7
import type { Ctx } from "./ctx" ;
8
8
import { createTaskFromRunnable , prepareEnv } from "./run" ;
9
- import { execute , isCargoRunnableArgs , unwrapUndefinable , log , normalizeDriveLetter } from "./util" ;
9
+ import {
10
+ execute ,
11
+ isCargoRunnableArgs ,
12
+ unwrapUndefinable ,
13
+ log ,
14
+ normalizeDriveLetter ,
15
+ Env ,
16
+ } from "./util" ;
10
17
import type { Config } from "./config" ;
11
18
12
19
// Here we want to keep track on everything that's currently running
@@ -206,10 +213,7 @@ type SourceFileMap = {
206
213
destination : string ;
207
214
} ;
208
215
209
- async function discoverSourceFileMap (
210
- env : Record < string , string > ,
211
- cwd : string ,
212
- ) : Promise < SourceFileMap | undefined > {
216
+ async function discoverSourceFileMap ( env : Env , cwd : string ) : Promise < SourceFileMap | undefined > {
213
217
const sysroot = env [ "RUSTC_TOOLCHAIN" ] ;
214
218
if ( sysroot ) {
215
219
// let's try to use the default toolchain
@@ -232,7 +236,7 @@ type PropertyFetcher<Config, Input, Key extends keyof Config> = (
232
236
233
237
type DebugConfigProvider < Type extends string , DebugConfig extends BaseDebugConfig < Type > > = {
234
238
executableProperty : keyof DebugConfig ;
235
- environmentProperty : PropertyFetcher < DebugConfig , Record < string , string > , keyof DebugConfig > ;
239
+ environmentProperty : PropertyFetcher < DebugConfig , Env , keyof DebugConfig > ;
236
240
runnableArgsProperty : PropertyFetcher < DebugConfig , ra . CargoRunnableArgs , keyof DebugConfig > ;
237
241
sourceFileMapProperty ?: keyof DebugConfig ;
238
242
type : Type ;
@@ -276,7 +280,7 @@ const knownEngines: {
276
280
"environment" ,
277
281
Object . entries ( env ) . map ( ( entry ) => ( {
278
282
name : entry [ 0 ] ,
279
- value : entry [ 1 ] ,
283
+ value : entry [ 1 ] ?? "" ,
280
284
} ) ) ,
281
285
] ,
282
286
runnableArgsProperty : ( runnableArgs : ra . CargoRunnableArgs ) => [
@@ -304,10 +308,7 @@ const knownEngines: {
304
308
} ,
305
309
} ;
306
310
307
- async function getDebugExecutable (
308
- runnableArgs : ra . CargoRunnableArgs ,
309
- env : Record < string , string > ,
310
- ) : Promise < string > {
311
+ async function getDebugExecutable ( runnableArgs : ra . CargoRunnableArgs , env : Env ) : Promise < string > {
311
312
const cargo = new Cargo ( runnableArgs . workspaceRoot || "." , env ) ;
312
313
const executable = await cargo . executableFromArgs ( runnableArgs ) ;
313
314
@@ -328,7 +329,7 @@ function getDebugConfig(
328
329
runnable : ra . Runnable ,
329
330
runnableArgs : ra . CargoRunnableArgs ,
330
331
executable : string ,
331
- env : Record < string , string > ,
332
+ env : Env ,
332
333
sourceFileMap ?: Record < string , string > ,
333
334
) : vscode . DebugConfiguration {
334
335
const {
@@ -380,14 +381,14 @@ type CodeLldbDebugConfig = {
380
381
args : string [ ] ;
381
382
sourceMap : Record < string , string > | undefined ;
382
383
sourceLanguages : [ "rust" ] ;
383
- env : Record < string , string > ;
384
+ env : Env ;
384
385
} & BaseDebugConfig < "lldb" > ;
385
386
386
387
type NativeDebugConfig = {
387
388
target : string ;
388
389
// See https://github.com/WebFreak001/code-debug/issues/359
389
390
arguments : string ;
390
- env : Record < string , string > ;
391
+ env : Env ;
391
392
valuesFormatting : "prettyPrinters" ;
392
393
} & BaseDebugConfig < "gdb" > ;
393
394
0 commit comments