diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-31 17:38:55 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-31 17:38:55 +0000 |
commit | 6d23140ba03c77b28d94e042c94155899baba9da (patch) | |
tree | 3efa5daf54fe08cd1b310fa42c2ef469503fcedd /editors/code/src/commands/index.ts | |
parent | 1327aed7f6289043091aa9179282030c6f13ddbe (diff) | |
parent | 6368b40dd98b208da3758d4d1eed34cf276e3b09 (diff) |
Merge #2709
2709: Work around synchrnonisation issue r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'editors/code/src/commands/index.ts')
-rw-r--r-- | editors/code/src/commands/index.ts | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index c28709c8a..4431fdcf6 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts | |||
@@ -15,18 +15,21 @@ import { run, runSingle } from './runnables'; | |||
15 | 15 | ||
16 | function collectGarbage(ctx: Ctx): Cmd { | 16 | function collectGarbage(ctx: Ctx): Cmd { |
17 | return async () => { | 17 | return async () => { |
18 | ctx.client.sendRequest<null>('rust-analyzer/collectGarbage', null); | 18 | ctx.client?.sendRequest<null>('rust-analyzer/collectGarbage', null); |
19 | }; | 19 | }; |
20 | } | 20 | } |
21 | 21 | ||
22 | function showReferences(ctx: Ctx): Cmd { | 22 | function showReferences(ctx: Ctx): Cmd { |
23 | return (uri: string, position: lc.Position, locations: lc.Location[]) => { | 23 | return (uri: string, position: lc.Position, locations: lc.Location[]) => { |
24 | vscode.commands.executeCommand( | 24 | let client = ctx.client; |
25 | 'editor.action.showReferences', | 25 | if (client) { |
26 | vscode.Uri.parse(uri), | 26 | vscode.commands.executeCommand( |
27 | ctx.client.protocol2CodeConverter.asPosition(position), | 27 | 'editor.action.showReferences', |
28 | locations.map(ctx.client.protocol2CodeConverter.asLocation), | 28 | vscode.Uri.parse(uri), |
29 | ); | 29 | client.protocol2CodeConverter.asPosition(position), |
30 | locations.map(client.protocol2CodeConverter.asLocation), | ||
31 | ); | ||
32 | } | ||
30 | }; | 33 | }; |
31 | } | 34 | } |
32 | 35 | ||
@@ -36,6 +39,13 @@ function applySourceChange(ctx: Ctx): Cmd { | |||
36 | } | 39 | } |
37 | } | 40 | } |
38 | 41 | ||
42 | function reload(ctx: Ctx): Cmd { | ||
43 | return async () => { | ||
44 | vscode.window.showInformationMessage('Reloading rust-analyzer...'); | ||
45 | await ctx.restartServer(); | ||
46 | } | ||
47 | } | ||
48 | |||
39 | export { | 49 | export { |
40 | analyzerStatus, | 50 | analyzerStatus, |
41 | expandMacro, | 51 | expandMacro, |
@@ -49,4 +59,5 @@ export { | |||
49 | runSingle, | 59 | runSingle, |
50 | showReferences, | 60 | showReferences, |
51 | applySourceChange, | 61 | applySourceChange, |
62 | reload | ||
52 | }; | 63 | }; |