diff options
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/commands.ts | 25 | ||||
-rw-r--r-- | editors/code/src/debug.ts | 5 | ||||
-rw-r--r-- | editors/code/src/main.ts | 15 | ||||
-rw-r--r-- | editors/code/src/run.ts | 7 |
4 files changed, 21 insertions, 31 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index 4170b9ccb..3729a71de 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts | |||
@@ -125,12 +125,11 @@ export function joinLines(ctx: Ctx): Cmd { | |||
125 | ranges: editor.selections.map((it) => client.code2ProtocolConverter.asRange(it)), | 125 | ranges: editor.selections.map((it) => client.code2ProtocolConverter.asRange(it)), |
126 | textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), | 126 | textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), |
127 | }); | 127 | }); |
128 | editor.edit((builder) => { | 128 | await editor.edit((builder) => { |
129 | client.protocol2CodeConverter.asTextEdits(items).forEach((edit: any) => { | 129 | client.protocol2CodeConverter.asTextEdits(items).forEach((edit: any) => { |
130 | builder.replace(edit.range, edit.newText); | 130 | builder.replace(edit.range, edit.newText); |
131 | }); | 131 | }); |
132 | }) | 132 | }); |
133 | .then(() => { }, console.error); | ||
134 | }; | 133 | }; |
135 | } | 134 | } |
136 | 135 | ||
@@ -237,7 +236,7 @@ export function ssr(ctx: Ctx): Cmd { | |||
237 | const request = await vscode.window.showInputBox(options); | 236 | const request = await vscode.window.showInputBox(options); |
238 | if (!request) return; | 237 | if (!request) return; |
239 | 238 | ||
240 | vscode.window.withProgress({ | 239 | await vscode.window.withProgress({ |
241 | location: vscode.ProgressLocation.Notification, | 240 | location: vscode.ProgressLocation.Notification, |
242 | title: "Structured search replace in progress...", | 241 | title: "Structured search replace in progress...", |
243 | cancellable: false, | 242 | cancellable: false, |
@@ -247,8 +246,7 @@ export function ssr(ctx: Ctx): Cmd { | |||
247 | }); | 246 | }); |
248 | 247 | ||
249 | await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit)); | 248 | await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit)); |
250 | }) | 249 | }); |
251 | .then(() => { }, console.error); | ||
252 | }; | 250 | }; |
253 | } | 251 | } |
254 | 252 | ||
@@ -459,16 +457,15 @@ export function reloadWorkspace(ctx: Ctx): Cmd { | |||
459 | } | 457 | } |
460 | 458 | ||
461 | export function showReferences(ctx: Ctx): Cmd { | 459 | export function showReferences(ctx: Ctx): Cmd { |
462 | return (uri: string, position: lc.Position, locations: lc.Location[]) => { | 460 | return async (uri: string, position: lc.Position, locations: lc.Location[]) => { |
463 | const client = ctx.client; | 461 | const client = ctx.client; |
464 | if (client) { | 462 | if (client) { |
465 | vscode.commands.executeCommand( | 463 | await vscode.commands.executeCommand( |
466 | 'editor.action.showReferences', | 464 | 'editor.action.showReferences', |
467 | vscode.Uri.parse(uri), | 465 | vscode.Uri.parse(uri), |
468 | client.protocol2CodeConverter.asPosition(position), | 466 | client.protocol2CodeConverter.asPosition(position), |
469 | locations.map(client.protocol2CodeConverter.asLocation), | 467 | locations.map(client.protocol2CodeConverter.asLocation), |
470 | ) | 468 | ); |
471 | .then(() => { }, console.error); | ||
472 | } | 469 | } |
473 | }; | 470 | }; |
474 | } | 471 | } |
@@ -477,11 +474,10 @@ export function applyActionGroup(_ctx: Ctx): Cmd { | |||
477 | return async (actions: { label: string; arguments: lc.CodeAction }[]) => { | 474 | return async (actions: { label: string; arguments: lc.CodeAction }[]) => { |
478 | const selectedAction = await vscode.window.showQuickPick(actions); | 475 | const selectedAction = await vscode.window.showQuickPick(actions); |
479 | if (!selectedAction) return; | 476 | if (!selectedAction) return; |
480 | vscode.commands.executeCommand( | 477 | await vscode.commands.executeCommand( |
481 | 'rust-analyzer.resolveCodeAction', | 478 | 'rust-analyzer.resolveCodeAction', |
482 | selectedAction.arguments, | 479 | selectedAction.arguments, |
483 | ) | 480 | ); |
484 | .then(() => { }, console.error); | ||
485 | }; | 481 | }; |
486 | } | 482 | } |
487 | 483 | ||
@@ -514,8 +510,7 @@ export function openDocs(ctx: Ctx): Cmd { | |||
514 | const doclink = await client.sendRequest(ra.openDocs, { position, textDocument }); | 510 | const doclink = await client.sendRequest(ra.openDocs, { position, textDocument }); |
515 | 511 | ||
516 | if (doclink != null) { | 512 | if (doclink != null) { |
517 | vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(doclink)) | 513 | await vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(doclink)); |
518 | .then(() => { }, console.error); | ||
519 | } | 514 | } |
520 | }; | 515 | }; |
521 | 516 | ||
diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index c72a7b278..3889a2773 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts | |||
@@ -77,9 +77,8 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v | |||
77 | } | 77 | } |
78 | 78 | ||
79 | if (!debugEngine) { | 79 | if (!debugEngine) { |
80 | vscode.window.showErrorMessage(`Install [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb)` | 80 | await vscode.window.showErrorMessage(`Install [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb)` |
81 | + ` or [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) extension for debugging.`) | 81 | + ` or [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) extension for debugging.`); |
82 | .then(() => { }, console.error); | ||
83 | return; | 82 | return; |
84 | } | 83 | } |
85 | 84 | ||
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index ecbe4e3c9..5c0b0be26 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -76,8 +76,7 @@ async function tryActivate(context: vscode.ExtensionContext) { | |||
76 | // This a horribly, horribly wrong way to deal with this problem. | 76 | // This a horribly, horribly wrong way to deal with this problem. |
77 | ctx = await Ctx.create(config, context, serverPath, workspaceFolder.uri.fsPath); | 77 | ctx = await Ctx.create(config, context, serverPath, workspaceFolder.uri.fsPath); |
78 | 78 | ||
79 | setContextValue(RUST_PROJECT_CONTEXT_NAME, true) | 79 | await setContextValue(RUST_PROJECT_CONTEXT_NAME, true); |
80 | .then(() => { }, console.error); | ||
81 | 80 | ||
82 | // Commands which invokes manually via command palette, shortcut, etc. | 81 | // Commands which invokes manually via command palette, shortcut, etc. |
83 | 82 | ||
@@ -143,8 +142,7 @@ async function tryActivate(context: vscode.ExtensionContext) { | |||
143 | } | 142 | } |
144 | 143 | ||
145 | export async function deactivate() { | 144 | export async function deactivate() { |
146 | setContextValue(RUST_PROJECT_CONTEXT_NAME, undefined) | 145 | await setContextValue(RUST_PROJECT_CONTEXT_NAME, undefined); |
147 | .then(() => { }, console.error); | ||
148 | await ctx?.client.stop(); | 146 | await ctx?.client.stop(); |
149 | ctx = undefined; | 147 | ctx = undefined; |
150 | } | 148 | } |
@@ -185,11 +183,10 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi | |||
185 | 183 | ||
186 | const release = await downloadWithRetryDialog(state, async () => { | 184 | const release = await downloadWithRetryDialog(state, async () => { |
187 | return await fetchRelease("nightly", state.githubToken); | 185 | return await fetchRelease("nightly", state.githubToken); |
188 | }).catch((e) => { | 186 | }).catch(async (e) => { |
189 | log.error(e); | 187 | log.error(e); |
190 | if (state.releaseId === undefined) { // Show error only for the initial download | 188 | if (state.releaseId === undefined) { // Show error only for the initial download |
191 | vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly ${e}`) | 189 | await vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly ${e}`); |
192 | .then(() => { }, console.error); | ||
193 | } | 190 | } |
194 | return undefined; | 191 | return undefined; |
195 | }); | 192 | }); |
@@ -301,14 +298,14 @@ async function getServer(config: Config, state: PersistentState): Promise<string | |||
301 | }; | 298 | }; |
302 | const platform = platforms[`${process.arch} ${process.platform}`]; | 299 | const platform = platforms[`${process.arch} ${process.platform}`]; |
303 | if (platform === undefined) { | 300 | if (platform === undefined) { |
304 | vscode.window.showErrorMessage( | 301 | await vscode.window.showErrorMessage( |
305 | "Unfortunately we don't ship binaries for your platform yet. " + | 302 | "Unfortunately we don't ship binaries for your platform yet. " + |
306 | "You need to manually clone rust-analyzer repository and " + | 303 | "You need to manually clone rust-analyzer repository and " + |
307 | "run `cargo xtask install --server` to build the language server from sources. " + | 304 | "run `cargo xtask install --server` to build the language server from sources. " + |
308 | "If you feel that your platform should be supported, please create an issue " + | 305 | "If you feel that your platform should be supported, please create an issue " + |
309 | "about that [here](https://github.com/rust-analyzer/rust-analyzer/issues) and we " + | 306 | "about that [here](https://github.com/rust-analyzer/rust-analyzer/issues) and we " + |
310 | "will consider it." | 307 | "will consider it." |
311 | ).then(() => { }, console.error); | 308 | ); |
312 | return undefined; | 309 | return undefined; |
313 | } | 310 | } |
314 | const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : ""; | 311 | const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : ""; |
diff --git a/editors/code/src/run.ts b/editors/code/src/run.ts index 331f85cd3..7ac7ca3cb 100644 --- a/editors/code/src/run.ts +++ b/editors/code/src/run.ts | |||
@@ -45,8 +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 | .then(() => { }, console.error); | ||
50 | return; | 49 | return; |
51 | } | 50 | } |
52 | 51 | ||
@@ -66,8 +65,8 @@ export async function selectRunnable(ctx: Ctx, prevRunnable?: RunnableQuickPick, | |||
66 | disposables.push( | 65 | disposables.push( |
67 | quickPick.onDidHide(() => close()), | 66 | quickPick.onDidHide(() => close()), |
68 | quickPick.onDidAccept(() => close(quickPick.selectedItems[0])), | 67 | quickPick.onDidAccept(() => close(quickPick.selectedItems[0])), |
69 | quickPick.onDidTriggerButton((_button) => { | 68 | quickPick.onDidTriggerButton(async (_button) => { |
70 | makeDebugConfig(ctx, quickPick.activeItems[0].runnable).catch(console.error); | 69 | await makeDebugConfig(ctx, quickPick.activeItems[0].runnable); |
71 | close(); | 70 | close(); |
72 | }), | 71 | }), |
73 | quickPick.onDidChangeActive((active) => { | 72 | quickPick.onDidChangeActive((active) => { |