@@ -4,6 +4,7 @@ import * as path from "path";
4
4
import * as readline from "readline" ;
5
5
import * as vscode from "vscode" ;
6
6
import { execute , log , memoizeAsync , unwrapNullable , unwrapUndefinable } from "./util" ;
7
+ import type { CargoRunnableArgs } from "./lsp_ext" ;
7
8
8
9
interface CompilationArtifact {
9
10
fileName : string ;
@@ -25,9 +26,8 @@ export class Cargo {
25
26
) { }
26
27
27
28
// Made public for testing purposes
28
- static artifactSpec ( args : readonly string [ ] ) : ArtifactSpec {
29
- const cargoArgs = [ ...args , "--message-format=json" ] ;
30
-
29
+ static artifactSpec ( cargoArgs : string [ ] , executableArgs ?: string [ ] ) : ArtifactSpec {
30
+ cargoArgs = [ ...cargoArgs , "--message-format=json" ] ;
31
31
// arguments for a runnable from the quick pick should be updated.
32
32
// see crates\rust-analyzer\src\main_loop\handlers.rs, handle_code_lens
33
33
switch ( cargoArgs [ 0 ] ) {
@@ -48,6 +48,9 @@ export class Cargo {
48
48
// produce 2 artifacts: {"kind": "bin"} and {"kind": "test"}
49
49
result . filter = ( artifacts ) => artifacts . filter ( ( it ) => it . isTest ) ;
50
50
}
51
+ if ( executableArgs ) {
52
+ cargoArgs . push ( "--" , ...executableArgs ) ;
53
+ }
51
54
52
55
return result ;
53
56
}
@@ -84,8 +87,10 @@ export class Cargo {
84
87
return spec . filter ?.( artifacts ) ?? artifacts ;
85
88
}
86
89
87
- async executableFromArgs ( args : readonly string [ ] ) : Promise < string > {
88
- const artifacts = await this . getArtifacts ( Cargo . artifactSpec ( args ) ) ;
90
+ async executableFromArgs ( runnableArgs : CargoRunnableArgs ) : Promise < string > {
91
+ const artifacts = await this . getArtifacts (
92
+ Cargo . artifactSpec ( runnableArgs . cargoArgs , runnableArgs . executableArgs ) ,
93
+ ) ;
89
94
90
95
if ( artifacts . length === 0 ) {
91
96
throw new Error ( "No compilation artifacts" ) ;
0 commit comments