diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-31 17:51:08 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-31 17:51:08 +0000 |
commit | c8b98c46675396c4f9d26c6b001e01c81d84b89e (patch) | |
tree | 40582f9bb4331676a0a469b728a5e6cfe1df5300 /editors/code/src/commands/parent_module.ts | |
parent | 6d23140ba03c77b28d94e042c94155899baba9da (diff) | |
parent | cb41ffbbbdea66d3a0abae4d270da1224a5de91c (diff) |
Merge #2710
2710: Fix NPEs r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'editors/code/src/commands/parent_module.ts')
-rw-r--r-- | editors/code/src/commands/parent_module.ts | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/editors/code/src/commands/parent_module.ts b/editors/code/src/commands/parent_module.ts index 258b61b21..bf40b4021 100644 --- a/editors/code/src/commands/parent_module.ts +++ b/editors/code/src/commands/parent_module.ts | |||
@@ -6,23 +6,24 @@ import { Ctx, Cmd } from '../ctx'; | |||
6 | export function parentModule(ctx: Ctx): Cmd { | 6 | export function parentModule(ctx: Ctx): Cmd { |
7 | return async () => { | 7 | return async () => { |
8 | const editor = ctx.activeRustEditor; | 8 | const editor = ctx.activeRustEditor; |
9 | if (!editor) return; | 9 | const client = ctx.client; |
10 | if (!editor || !client) return; | ||
10 | 11 | ||
11 | const request: lc.TextDocumentPositionParams = { | 12 | const request: lc.TextDocumentPositionParams = { |
12 | textDocument: { uri: editor.document.uri.toString() }, | 13 | textDocument: { uri: editor.document.uri.toString() }, |
13 | position: ctx.client.code2ProtocolConverter.asPosition( | 14 | position: client.code2ProtocolConverter.asPosition( |
14 | editor.selection.active, | 15 | editor.selection.active, |
15 | ), | 16 | ), |
16 | }; | 17 | }; |
17 | const response = await ctx.client.sendRequest<lc.Location[]>( | 18 | const response = await client.sendRequest<lc.Location[]>( |
18 | 'rust-analyzer/parentModule', | 19 | 'rust-analyzer/parentModule', |
19 | request, | 20 | request, |
20 | ); | 21 | ); |
21 | const loc = response[0]; | 22 | const loc = response[0]; |
22 | if (loc == null) return; | 23 | if (loc == null) return; |
23 | 24 | ||
24 | const uri = ctx.client.protocol2CodeConverter.asUri(loc.uri); | 25 | const uri = client.protocol2CodeConverter.asUri(loc.uri); |
25 | const range = ctx.client.protocol2CodeConverter.asRange(loc.range); | 26 | const range = client.protocol2CodeConverter.asRange(loc.range); |
26 | 27 | ||
27 | const doc = await vscode.workspace.openTextDocument(uri); | 28 | const doc = await vscode.workspace.openTextDocument(uri); |
28 | const e = await vscode.window.showTextDocument(doc); | 29 | const e = await vscode.window.showTextDocument(doc); |