From cb41ffbbbdea66d3a0abae4d270da1224a5de91c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 31 Dec 2019 18:50:32 +0100 Subject: Fix NPEs --- editors/code/src/commands/parent_module.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'editors/code/src/commands/parent_module.ts') 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'; export function parentModule(ctx: Ctx): Cmd { return async () => { const editor = ctx.activeRustEditor; - if (!editor) return; + const client = ctx.client; + if (!editor || !client) return; const request: lc.TextDocumentPositionParams = { textDocument: { uri: editor.document.uri.toString() }, - position: ctx.client.code2ProtocolConverter.asPosition( + position: client.code2ProtocolConverter.asPosition( editor.selection.active, ), }; - const response = await ctx.client.sendRequest( + const response = await client.sendRequest( 'rust-analyzer/parentModule', request, ); const loc = response[0]; if (loc == null) return; - const uri = ctx.client.protocol2CodeConverter.asUri(loc.uri); - const range = ctx.client.protocol2CodeConverter.asRange(loc.range); + const uri = client.protocol2CodeConverter.asUri(loc.uri); + const range = client.protocol2CodeConverter.asRange(loc.range); const doc = await vscode.workspace.openTextDocument(uri); const e = await vscode.window.showTextDocument(doc); -- cgit v1.2.3