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/syntax_tree.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'editors/code/src/commands/syntax_tree.ts') diff --git a/editors/code/src/commands/syntax_tree.ts b/editors/code/src/commands/syntax_tree.ts index 5b8f6e4d9..2ee80f910 100644 --- a/editors/code/src/commands/syntax_tree.ts +++ b/editors/code/src/commands/syntax_tree.ts @@ -76,7 +76,8 @@ class TextDocumentContentProvider provideTextDocumentContent(uri: vscode.Uri): vscode.ProviderResult { const editor = vscode.window.activeTextEditor; - if (editor == null) return ''; + const client = this.ctx.client + if (!editor || !client) return ''; let range: lc.Range | undefined; @@ -84,16 +85,14 @@ class TextDocumentContentProvider if (uri.query === 'range=true') { range = editor.selection.isEmpty ? undefined - : this.ctx.client.code2ProtocolConverter.asRange( - editor.selection, - ); + : client.code2ProtocolConverter.asRange(editor.selection); } const request: SyntaxTreeParams = { textDocument: { uri: editor.document.uri.toString() }, range, }; - return this.ctx.client.sendRequest( + return client.sendRequest( 'rust-analyzer/syntaxTree', request, ); -- cgit v1.2.3