aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
authorDmitry <[email protected]>2020-08-09 14:35:51 +0100
committerDmitry <[email protected]>2020-08-09 14:39:32 +0100
commit8068302fefc75440b823f4bf1731a5f347d7c767 (patch)
tree251b967182e79bc82a58c2fb208c688f6152df1f /editors/code
parent1a43a0f63e0008787225abb6fb2baef97b6a39e0 (diff)
parent8a57afe5a4bfab40072a83f7dc4ca560bf860919 (diff)
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/package.json10
-rw-r--r--editors/code/src/commands.ts5
-rw-r--r--editors/code/src/debug.ts12
-rw-r--r--editors/code/src/lsp_ext.ts1
4 files changed, 23 insertions, 5 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index 658c913fd..ee5f96bf3 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -323,6 +323,14 @@
323 "default": true, 323 "default": true,
324 "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)" 324 "markdownDescription": "Check all targets and tests (will be passed as `--all-targets`)"
325 }, 325 },
326 "rust-analyzer.checkOnSave.noDefaultFeatures": {
327 "type": [
328 "null",
329 "boolean"
330 ],
331 "default": null,
332 "markdownDescription": "Do not activate the `default` feature"
333 },
326 "rust-analyzer.checkOnSave.allFeatures": { 334 "rust-analyzer.checkOnSave.allFeatures": {
327 "type": [ 335 "type": [
328 "null", 336 "null",
@@ -599,7 +607,7 @@
599 "items": { 607 "items": {
600 "type": "string" 608 "type": "string"
601 }, 609 },
602 "description": "List of warnings warnings that should be displayed with hint severity.\nThe warnings will be indicated by faded text or three dots in code and will not show up in the problems panel.", 610 "description": "List of warnings that should be displayed with hint severity.\nThe warnings will be indicated by faded text or three dots in code and will not show up in the problems panel.",
603 "default": [] 611 "default": []
604 } 612 }
605 } 613 }
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index c21e5597c..d0faf4745 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -190,6 +190,7 @@ export function ssr(ctx: Ctx): Cmd {
190 if (!editor || !client) return; 190 if (!editor || !client) return;
191 191
192 const position = editor.selection.active; 192 const position = editor.selection.active;
193 const selections = editor.selections;
193 const textDocument = { uri: editor.document.uri.toString() }; 194 const textDocument = { uri: editor.document.uri.toString() };
194 195
195 const options: vscode.InputBoxOptions = { 196 const options: vscode.InputBoxOptions = {
@@ -198,7 +199,7 @@ export function ssr(ctx: Ctx): Cmd {
198 validateInput: async (x: string) => { 199 validateInput: async (x: string) => {
199 try { 200 try {
200 await client.sendRequest(ra.ssr, { 201 await client.sendRequest(ra.ssr, {
201 query: x, parseOnly: true, textDocument, position, 202 query: x, parseOnly: true, textDocument, position, selections,
202 }); 203 });
203 } catch (e) { 204 } catch (e) {
204 return e.toString(); 205 return e.toString();
@@ -215,7 +216,7 @@ export function ssr(ctx: Ctx): Cmd {
215 cancellable: false, 216 cancellable: false,
216 }, async (_progress, _token) => { 217 }, async (_progress, _token) => {
217 const edit = await client.sendRequest(ra.ssr, { 218 const edit = await client.sendRequest(ra.ssr, {
218 query: request, parseOnly: false, textDocument, position 219 query: request, parseOnly: false, textDocument, position, selections,
219 }); 220 });
220 221
221 await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit)); 222 await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit));
diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts
index bd92c5b6d..925126a16 100644
--- a/editors/code/src/debug.ts
+++ b/editors/code/src/debug.ts
@@ -87,9 +87,17 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v
87 debugOutput.show(true); 87 debugOutput.show(true);
88 } 88 }
89 89
90 const wsFolder = path.normalize(vscode.workspace.workspaceFolders![0].uri.fsPath); // folder exists or RA is not active. 90 const isMultiFolderWorkspace = vscode.workspace.workspaceFolders!.length > 1;
91 const firstWorkspace = vscode.workspace.workspaceFolders![0]; // folder exists or RA is not active.
92 const workspace = !isMultiFolderWorkspace || !runnable.args.workspaceRoot ?
93 firstWorkspace :
94 vscode.workspace.workspaceFolders!.find(w => runnable.args.workspaceRoot?.includes(w.uri.fsPath)) || firstWorkspace;
95
96 const wsFolder = path.normalize(workspace.uri.fsPath);
97 const workspaceQualifier = isMultiFolderWorkspace ? `:${workspace.name}` : '';
91 function simplifyPath(p: string): string { 98 function simplifyPath(p: string): string {
92 return path.normalize(p).replace(wsFolder, '${workspaceRoot}'); 99 // see https://github.com/rust-analyzer/rust-analyzer/pull/5513#issuecomment-663458818 for why this is needed
100 return path.normalize(p).replace(wsFolder, '${workspaceFolder' + workspaceQualifier + '}');
93 } 101 }
94 102
95 const executable = await getDebugExecutable(runnable); 103 const executable = await getDebugExecutable(runnable);
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts
index 149f9a0d6..494d51c83 100644
--- a/editors/code/src/lsp_ext.ts
+++ b/editors/code/src/lsp_ext.ts
@@ -95,6 +95,7 @@ export interface SsrParams {
95 parseOnly: boolean; 95 parseOnly: boolean;
96 textDocument: lc.TextDocumentIdentifier; 96 textDocument: lc.TextDocumentIdentifier;
97 position: lc.Position; 97 position: lc.Position;
98 selections: lc.Range[];
98} 99}
99export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr'); 100export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr');
100 101