aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/package.json9
-rw-r--r--editors/code/src/client.ts7
-rw-r--r--editors/code/src/ctx.ts1
-rw-r--r--editors/code/src/main.ts7
-rw-r--r--editors/code/src/run.ts4
-rw-r--r--editors/code/src/snippets.ts2
-rw-r--r--editors/code/src/tasks.ts27
7 files changed, 32 insertions, 25 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index 17d9281ff..5b80cc1f9 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -597,7 +597,7 @@
597 "type": "object" 597 "type": "object"
598 }, 598 },
599 "rust-analyzer.diagnostics.warningsAsHint": { 599 "rust-analyzer.diagnostics.warningsAsHint": {
600 "markdownDescription": "List of warnings that should be displayed with info severity.\n\nThe warnings will be indicated by a blue squiggly underline in code\nand a blue icon in the `Problems Panel`.", 600 "markdownDescription": "List of warnings that should be displayed with hint severity.\n\nThe warnings will be indicated by faded text or three dots in code\nand will not show up in the `Problems Panel`.",
601 "default": [], 601 "default": [],
602 "type": "array", 602 "type": "array",
603 "items": { 603 "items": {
@@ -605,7 +605,7 @@
605 } 605 }
606 }, 606 },
607 "rust-analyzer.diagnostics.warningsAsInfo": { 607 "rust-analyzer.diagnostics.warningsAsInfo": {
608 "markdownDescription": "List of warnings that should be displayed with hint severity.\n\nThe warnings will be indicated by faded text or three dots in code\nand will not show up in the `Problems Panel`.", 608 "markdownDescription": "List of warnings that should be displayed with info severity.\n\nThe warnings will be indicated by a blue squiggly underline in code\nand a blue icon in the `Problems Panel`.",
609 "default": [], 609 "default": [],
610 "type": "array", 610 "type": "array",
611 "items": { 611 "items": {
@@ -795,6 +795,11 @@
795 "type": "string" 795 "type": "string"
796 } 796 }
797 }, 797 },
798 "rust-analyzer.rustfmt.enableRangeFormatting": {
799 "markdownDescription": "Enables the use of rustfmt's unstable range formatting command for the\n`textDocument/rangeFormatting` request. The rustfmt option is unstable and only\navailable on a nightly build.",
800 "default": false,
801 "type": "boolean"
802 },
798 "rust-analyzer.workspace.symbol.search.scope": { 803 "rust-analyzer.workspace.symbol.search.scope": {
799 "markdownDescription": "Workspace symbol search scope.", 804 "markdownDescription": "Workspace symbol search scope.",
800 "default": "workspace", 805 "default": "workspace",
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 69dbe2535..f13ae07e1 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -32,14 +32,9 @@ export function createClient(serverPath: string, workspace: Workspace, extraEnv:
32 const newEnv = Object.assign({}, process.env); 32 const newEnv = Object.assign({}, process.env);
33 Object.assign(newEnv, extraEnv); 33 Object.assign(newEnv, extraEnv);
34 34
35 let cwd = undefined;
36 if (workspace.kind === "Workspace Folder") {
37 cwd = workspace.folder.fsPath;
38 };
39
40 const run: lc.Executable = { 35 const run: lc.Executable = {
41 command: serverPath, 36 command: serverPath,
42 options: { cwd, env: newEnv }, 37 options: { env: newEnv },
43 }; 38 };
44 const serverOptions: lc.ServerOptions = { 39 const serverOptions: lc.ServerOptions = {
45 run, 40 run,
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index 22c5f62a1..cf67dd8cf 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -10,7 +10,6 @@ import { ServerStatusParams } from './lsp_ext';
10export type Workspace = 10export type Workspace =
11 { 11 {
12 kind: 'Workspace Folder'; 12 kind: 'Workspace Folder';
13 folder: vscode.Uri;
14 } 13 }
15 | { 14 | {
16 kind: 'Detached Files'; 15 kind: 'Detached Files';
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index b735186fe..d26273246 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -45,8 +45,7 @@ async function tryActivate(context: vscode.ExtensionContext) {
45 throw new Error(message); 45 throw new Error(message);
46 }); 46 });
47 47
48 const workspaceFolder = vscode.workspace.workspaceFolders?.[0]; 48 if (vscode.workspace.workspaceFolders?.length === 0) {
49 if (workspaceFolder === undefined) {
50 const rustDocuments = vscode.workspace.textDocuments.filter(document => isRustDocument(document)); 49 const rustDocuments = vscode.workspace.textDocuments.filter(document => isRustDocument(document));
51 if (rustDocuments.length > 0) { 50 if (rustDocuments.length > 0) {
52 ctx = await Ctx.create(config, context, serverPath, { kind: 'Detached Files', files: rustDocuments }); 51 ctx = await Ctx.create(config, context, serverPath, { kind: 'Detached Files', files: rustDocuments });
@@ -58,8 +57,8 @@ async function tryActivate(context: vscode.ExtensionContext) {
58 // registers its `onDidChangeDocument` handler before us. 57 // registers its `onDidChangeDocument` handler before us.
59 // 58 //
60 // This a horribly, horribly wrong way to deal with this problem. 59 // This a horribly, horribly wrong way to deal with this problem.
61 ctx = await Ctx.create(config, context, serverPath, { kind: "Workspace Folder", folder: workspaceFolder.uri }); 60 ctx = await Ctx.create(config, context, serverPath, { kind: "Workspace Folder" });
62 ctx.pushCleanup(activateTaskProvider(workspaceFolder, ctx.config)); 61 ctx.pushCleanup(activateTaskProvider(ctx.config));
63 } 62 }
64 await initCommonContext(context, ctx); 63 await initCommonContext(context, ctx);
65 64
diff --git a/editors/code/src/run.ts b/editors/code/src/run.ts
index 138e3f686..d0be84068 100644
--- a/editors/code/src/run.ts
+++ b/editors/code/src/run.ts
@@ -142,7 +142,11 @@ export async function createTask(runnable: ra.Runnable, config: Config): Promise
142 // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion 142 // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
143 const target = vscode.workspace.workspaceFolders![0]; // safe, see main activate() 143 const target = vscode.workspace.workspaceFolders![0]; // safe, see main activate()
144 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);
145
145 cargoTask.presentationOptions.clear = true; 146 cargoTask.presentationOptions.clear = true;
147 // Sadly, this doesn't prevent focus stealing if the terminal is currently
148 // hidden, and will become revealed due to task exucution.
149 cargoTask.presentationOptions.focus = false;
146 150
147 return cargoTask; 151 return cargoTask;
148} 152}
diff --git a/editors/code/src/snippets.ts b/editors/code/src/snippets.ts
index 58f7aa128..a409e5296 100644
--- a/editors/code/src/snippets.ts
+++ b/editors/code/src/snippets.ts
@@ -52,7 +52,7 @@ export async function applySnippetTextEdits(editor: vscode.TextEditor, edits: vs
52 } else { 52 } else {
53 builder.replace(indel.range, indel.newText); 53 builder.replace(indel.range, indel.newText);
54 } 54 }
55 lineDelta = countLines(indel.newText) - (indel.range.end.line - indel.range.start.line); 55 lineDelta += countLines(indel.newText) - (indel.range.end.line - indel.range.start.line);
56 } 56 }
57 }); 57 });
58 if (selections.length > 0) editor.selections = selections; 58 if (selections.length > 0) editor.selections = selections;
diff --git a/editors/code/src/tasks.ts b/editors/code/src/tasks.ts
index a3ff15102..694ee1e41 100644
--- a/editors/code/src/tasks.ts
+++ b/editors/code/src/tasks.ts
@@ -17,11 +17,9 @@ export interface CargoTaskDefinition extends vscode.TaskDefinition {
17} 17}
18 18
19class CargoTaskProvider implements vscode.TaskProvider { 19class CargoTaskProvider implements vscode.TaskProvider {
20 private readonly target: vscode.WorkspaceFolder;
21 private readonly config: Config; 20 private readonly config: Config;
22 21
23 constructor(target: vscode.WorkspaceFolder, config: Config) { 22 constructor(config: Config) {
24 this.target = target;
25 this.config = config; 23 this.config = config;
26 } 24 }
27 25
@@ -40,10 +38,12 @@ class CargoTaskProvider implements vscode.TaskProvider {
40 ]; 38 ];
41 39
42 const tasks: vscode.Task[] = []; 40 const tasks: vscode.Task[] = [];
43 for (const def of defs) { 41 for (const workspaceTarget of vscode.workspace.workspaceFolders || []) {
44 const vscodeTask = await buildCargoTask(this.target, { type: TASK_TYPE, command: def.command }, `cargo ${def.command}`, [def.command], this.config.cargoRunner); 42 for (const def of defs) {
45 vscodeTask.group = def.group; 43 const vscodeTask = await buildCargoTask(workspaceTarget, { type: TASK_TYPE, command: def.command }, `cargo ${def.command}`, [def.command], this.config.cargoRunner);
46 tasks.push(vscodeTask); 44 vscodeTask.group = def.group;
45 tasks.push(vscodeTask);
46 }
47 } 47 }
48 48
49 return tasks; 49 return tasks;
@@ -58,14 +58,19 @@ class CargoTaskProvider implements vscode.TaskProvider {
58 58
59 if (definition.type === TASK_TYPE && definition.command) { 59 if (definition.type === TASK_TYPE && definition.command) {
60 const args = [definition.command].concat(definition.args ?? []); 60 const args = [definition.command].concat(definition.args ?? []);
61 61 if (isWorkspaceFolder(task.scope)) {
62 return await buildCargoTask(this.target, definition, task.name, args, this.config.cargoRunner); 62 return await buildCargoTask(task.scope, definition, task.name, args, this.config.cargoRunner);
63 }
63 } 64 }
64 65
65 return undefined; 66 return undefined;
66 } 67 }
67} 68}
68 69
70function isWorkspaceFolder(scope?: any): scope is vscode.WorkspaceFolder {
71 return (scope as vscode.WorkspaceFolder).name !== undefined;
72}
73
69export async function buildCargoTask( 74export async function buildCargoTask(
70 target: vscode.WorkspaceFolder, 75 target: vscode.WorkspaceFolder,
71 definition: CargoTaskDefinition, 76 definition: CargoTaskDefinition,
@@ -119,7 +124,7 @@ export async function buildCargoTask(
119 ); 124 );
120} 125}
121 126
122export function activateTaskProvider(target: vscode.WorkspaceFolder, config: Config): vscode.Disposable { 127export function activateTaskProvider(config: Config): vscode.Disposable {
123 const provider = new CargoTaskProvider(target, config); 128 const provider = new CargoTaskProvider(config);
124 return vscode.tasks.registerTaskProvider(TASK_TYPE, provider); 129 return vscode.tasks.registerTaskProvider(TASK_TYPE, provider);
125} 130}