diff options
Diffstat (limited to 'editors/code/src/run.ts')
-rw-r--r-- | editors/code/src/run.ts | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/editors/code/src/run.ts b/editors/code/src/run.ts index 17573cd82..138e3f686 100644 --- a/editors/code/src/run.ts +++ b/editors/code/src/run.ts | |||
@@ -45,7 +45,7 @@ export async function selectRunnable(ctx: Ctx, prevRunnable?: RunnableQuickPick, | |||
45 | if (items.length === 0) { | 45 | if (items.length === 0) { |
46 | // it is the debug case, run always has at least 'cargo check ...' | 46 | // it is the debug case, run always has at least 'cargo check ...' |
47 | // see crates\rust-analyzer\src\main_loop\handlers.rs, handle_runnables | 47 | // see crates\rust-analyzer\src\main_loop\handlers.rs, handle_runnables |
48 | vscode.window.showErrorMessage("There's no debug target!"); | 48 | await vscode.window.showErrorMessage("There's no debug target!"); |
49 | return; | 49 | return; |
50 | } | 50 | } |
51 | 51 | ||
@@ -65,8 +65,8 @@ export async function selectRunnable(ctx: Ctx, prevRunnable?: RunnableQuickPick, | |||
65 | disposables.push( | 65 | disposables.push( |
66 | quickPick.onDidHide(() => close()), | 66 | quickPick.onDidHide(() => close()), |
67 | quickPick.onDidAccept(() => close(quickPick.selectedItems[0])), | 67 | quickPick.onDidAccept(() => close(quickPick.selectedItems[0])), |
68 | quickPick.onDidTriggerButton((_button) => { | 68 | quickPick.onDidTriggerButton(async (_button) => { |
69 | (async () => await makeDebugConfig(ctx, quickPick.activeItems[0].runnable))(); | 69 | await makeDebugConfig(ctx, quickPick.activeItems[0].runnable); |
70 | close(); | 70 | close(); |
71 | }), | 71 | }), |
72 | quickPick.onDidChangeActive((active) => { | 72 | quickPick.onDidChangeActive((active) => { |
@@ -128,13 +128,7 @@ export async function createTask(runnable: ra.Runnable, config: Config): Promise | |||
128 | throw `Unexpected runnable kind: ${runnable.kind}`; | 128 | throw `Unexpected runnable kind: ${runnable.kind}`; |
129 | } | 129 | } |
130 | 130 | ||
131 | const args = [...runnable.args.cargoArgs]; // should be a copy! | 131 | const args = createArgs(runnable); |
132 | if (runnable.args.cargoExtraArgs) { | ||
133 | args.push(...runnable.args.cargoExtraArgs); // Append user-specified cargo options. | ||
134 | } | ||
135 | if (runnable.args.executableArgs.length > 0) { | ||
136 | args.push('--', ...runnable.args.executableArgs); | ||
137 | } | ||
138 | 132 | ||
139 | const definition: tasks.CargoTaskDefinition = { | 133 | const definition: tasks.CargoTaskDefinition = { |
140 | type: tasks.TASK_TYPE, | 134 | type: tasks.TASK_TYPE, |
@@ -145,9 +139,21 @@ export async function createTask(runnable: ra.Runnable, config: Config): Promise | |||
145 | overrideCargo: runnable.args.overrideCargo, | 139 | overrideCargo: runnable.args.overrideCargo, |
146 | }; | 140 | }; |
147 | 141 | ||
142 | // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion | ||
148 | const target = vscode.workspace.workspaceFolders![0]; // safe, see main activate() | 143 | const target = vscode.workspace.workspaceFolders![0]; // safe, see main activate() |
149 | const cargoTask = await tasks.buildCargoTask(target, definition, runnable.label, args, config.cargoRunner, true); | 144 | const cargoTask = await tasks.buildCargoTask(target, definition, runnable.label, args, config.cargoRunner, true); |
150 | cargoTask.presentationOptions.clear = true; | 145 | cargoTask.presentationOptions.clear = true; |
151 | 146 | ||
152 | return cargoTask; | 147 | return cargoTask; |
153 | } | 148 | } |
149 | |||
150 | export function createArgs(runnable: ra.Runnable): string[] { | ||
151 | const args = [...runnable.args.cargoArgs]; // should be a copy! | ||
152 | if (runnable.args.cargoExtraArgs) { | ||
153 | args.push(...runnable.args.cargoExtraArgs); // Append user-specified cargo options. | ||
154 | } | ||
155 | if (runnable.args.executableArgs.length > 0) { | ||
156 | args.push('--', ...runnable.args.executableArgs); | ||
157 | } | ||
158 | return args; | ||
159 | } | ||