Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/commands.ts')
-rw-r--r--editors/code/src/commands.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index 7ebc186a3e..dc35fddf49 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -1139,11 +1139,37 @@ export function peekTests(ctx: CtxInit): Cmd {
};
}
+function isUpdatingTest(runnable: ra.Runnable): boolean {
+ if (!isCargoRunnableArgs(runnable.args)) {
+ return false;
+ }
+
+ const env = runnable.args.environment;
+ return env ? ['UPDATE_EXPECT', 'INSTA_UPDATE', 'SNAPSHOTS'].some(key => key in env) : false;
+}
+
export function runSingle(ctx: CtxInit): Cmd {
return async (runnable: ra.Runnable) => {
const editor = ctx.activeRustEditor;
if (!editor) return;
+ if (isUpdatingTest(runnable) && ctx.config.askBeforeUpdateTest) {
+ const selection = await vscode.window.showInformationMessage(
+ 'rust-analyzer',
+ { detail: 'Do you want to update tests?', modal: true },
+ 'Update Now',
+ 'Update (and Don\'t ask again)',
+ );
+
+ if (selection !== 'Update Now' && selection !== 'Update (and Don\'t ask again)') {
+ return;
+ }
+
+ if (selection === 'Update (and Don\'t ask again)') {
+ ctx.config.setAskBeforeUpdateTest(false);
+ }
+ }
+
const task = await createTaskFromRunnable(runnable, ctx.config);
task.group = vscode.TaskGroup.Build;
task.presentationOptions = {