diff options
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r-- | editors/code/src/main.ts | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index a46dbde33..7ba16120c 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -13,6 +13,7 @@ import { log, assert } from './util'; | |||
13 | import { PersistentState } from './persistent_state'; | 13 | import { PersistentState } from './persistent_state'; |
14 | import { fetchRelease, download } from './net'; | 14 | import { fetchRelease, download } from './net'; |
15 | import { spawnSync } from 'child_process'; | 15 | import { spawnSync } from 'child_process'; |
16 | import { activateTaskProvider } from './tasks'; | ||
16 | 17 | ||
17 | let ctx: Ctx | undefined; | 18 | let ctx: Ctx | undefined; |
18 | 19 | ||
@@ -41,11 +42,18 @@ export async function activate(context: vscode.ExtensionContext) { | |||
41 | const state = new PersistentState(context.globalState); | 42 | const state = new PersistentState(context.globalState); |
42 | const serverPath = await bootstrap(config, state); | 43 | const serverPath = await bootstrap(config, state); |
43 | 44 | ||
45 | const workspaceFolder = vscode.workspace.workspaceFolders?.[0]; | ||
46 | if (workspaceFolder === undefined) { | ||
47 | const err = "Cannot activate rust-analyzer when no folder is opened"; | ||
48 | void vscode.window.showErrorMessage(err); | ||
49 | throw new Error(err); | ||
50 | } | ||
51 | |||
44 | // Note: we try to start the server before we activate type hints so that it | 52 | // Note: we try to start the server before we activate type hints so that it |
45 | // registers its `onDidChangeDocument` handler before us. | 53 | // registers its `onDidChangeDocument` handler before us. |
46 | // | 54 | // |
47 | // This a horribly, horribly wrong way to deal with this problem. | 55 | // This a horribly, horribly wrong way to deal with this problem. |
48 | ctx = await Ctx.create(config, context, serverPath); | 56 | ctx = await Ctx.create(config, context, serverPath, workspaceFolder.uri.fsPath); |
49 | 57 | ||
50 | // Commands which invokes manually via command palette, shortcut, etc. | 58 | // Commands which invokes manually via command palette, shortcut, etc. |
51 | 59 | ||
@@ -85,6 +93,8 @@ export async function activate(context: vscode.ExtensionContext) { | |||
85 | ctx.registerCommand('applySourceChange', commands.applySourceChange); | 93 | ctx.registerCommand('applySourceChange', commands.applySourceChange); |
86 | ctx.registerCommand('selectAndApplySourceChange', commands.selectAndApplySourceChange); | 94 | ctx.registerCommand('selectAndApplySourceChange', commands.selectAndApplySourceChange); |
87 | 95 | ||
96 | ctx.pushCleanup(activateTaskProvider(workspaceFolder)); | ||
97 | |||
88 | activateStatusDisplay(ctx); | 98 | activateStatusDisplay(ctx); |
89 | 99 | ||
90 | if (!ctx.config.highlightingSemanticTokens) { | 100 | if (!ctx.config.highlightingSemanticTokens) { |