aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/config.ts4
-rw-r--r--editors/code/src/debug.ts2
-rw-r--r--editors/code/src/run.ts14
3 files changed, 10 insertions, 10 deletions
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index a317aabcb..3257275c5 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -5,7 +5,7 @@ export type UpdatesChannel = "stable" | "nightly";
5 5
6export const NIGHTLY_TAG = "nightly"; 6export const NIGHTLY_TAG = "nightly";
7 7
8export type RunnableEnvCfg = Record<string, string> | [{ mask?: string, env: Record<string, string>; }] 8export type RunnableEnvCfg = undefined | Record<string, string> | { mask?: string, env: Record<string, string>; }[];
9 9
10export class Config { 10export class Config {
11 readonly extensionId = "matklad.rust-analyzer"; 11 readonly extensionId = "matklad.rust-analyzer";
@@ -117,7 +117,7 @@ export class Config {
117 } 117 }
118 118
119 get runnableEnv() { 119 get runnableEnv() {
120 return this.get<RunnableEnvCfg | undefined>("runnableEnv"); 120 return this.get<RunnableEnvCfg>("runnableEnv");
121 } 121 }
122 122
123 get debug() { 123 get debug() {
diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts
index 525d26923..bd92c5b6d 100644
--- a/editors/code/src/debug.ts
+++ b/editors/code/src/debug.ts
@@ -93,7 +93,7 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v
93 } 93 }
94 94
95 const executable = await getDebugExecutable(runnable); 95 const executable = await getDebugExecutable(runnable);
96 const env = prepareEnv(runnable, ctx.config); 96 const env = prepareEnv(runnable, ctx.config.runnableEnv);
97 const debugConfig = knownEngines[debugEngine.id](runnable, simplifyPath(executable), env, debugOptions.sourceFileMap); 97 const debugConfig = knownEngines[debugEngine.id](runnable, simplifyPath(executable), env, debugOptions.sourceFileMap);
98 if (debugConfig.type in debugOptions.engineSettings) { 98 if (debugConfig.type in debugOptions.engineSettings) {
99 const settingsMap = (debugOptions.engineSettings as any)[debugConfig.type]; 99 const settingsMap = (debugOptions.engineSettings as any)[debugConfig.type];
diff --git a/editors/code/src/run.ts b/editors/code/src/run.ts
index d7c7c489c..4a5c6ad41 100644
--- a/editors/code/src/run.ts
+++ b/editors/code/src/run.ts
@@ -5,7 +5,7 @@ import * as tasks from './tasks';
5 5
6import { Ctx } from './ctx'; 6import { Ctx } from './ctx';
7import { makeDebugConfig } from './debug'; 7import { makeDebugConfig } from './debug';
8import { Config } from './config'; 8import { Config, RunnableEnvCfg } from './config';
9 9
10const quickPickButtons = [{ iconPath: new vscode.ThemeIcon("save"), tooltip: "Save as a launch.json configurtation." }]; 10const quickPickButtons = [{ iconPath: new vscode.ThemeIcon("save"), tooltip: "Save as a launch.json configurtation." }];
11 11
@@ -96,22 +96,22 @@ export class RunnableQuickPick implements vscode.QuickPickItem {
96 } 96 }
97} 97}
98 98
99export function prepareEnv(runnable: ra.Runnable, config: Config): Record<string, string> { 99export function prepareEnv(runnable: ra.Runnable, runnableEnvCfg: RunnableEnvCfg): Record<string, string> {
100 const env: Record<string, string> = { "RUST_BACKTRACE": "short" }; 100 const env: Record<string, string> = { "RUST_BACKTRACE": "short" };
101 101
102 if (runnable.args.expectTest) { 102 if (runnable.args.expectTest) {
103 env["UPDATE_EXPECT"] = "1"; 103 env["UPDATE_EXPECT"] = "1";
104 } 104 }
105 105
106 if (config.runnableEnv) { 106 if (runnableEnvCfg) {
107 if (Array.isArray(config.runnableEnv)) { 107 if (Array.isArray(runnableEnvCfg)) {
108 for (const it of config.runnableEnv) { 108 for (const it of runnableEnvCfg) {
109 if (!it.mask || new RegExp(it.mask).test(runnable.label)) { 109 if (!it.mask || new RegExp(it.mask).test(runnable.label)) {
110 Object.assign(env, it.env); 110 Object.assign(env, it.env);
111 } 111 }
112 } 112 }
113 } else { 113 } else {
114 Object.assign(env, config.runnableEnv as Record<string, string>); 114 Object.assign(env, runnableEnvCfg as Record<string, string>);
115 } 115 }
116 } 116 }
117 117
@@ -136,7 +136,7 @@ export async function createTask(runnable: ra.Runnable, config: Config): Promise
136 command: args[0], // run, test, etc... 136 command: args[0], // run, test, etc...
137 args: args.slice(1), 137 args: args.slice(1),
138 cwd: runnable.args.workspaceRoot, 138 cwd: runnable.args.workspaceRoot,
139 env: prepareEnv(runnable, config), 139 env: prepareEnv(runnable, config.runnableEnv),
140 }; 140 };
141 141
142 const target = vscode.workspace.workspaceFolders![0]; // safe, see main activate() 142 const target = vscode.workspace.workspaceFolders![0]; // safe, see main activate()