about summary refs log tree commit diff
path: root/editors/code/src/commands/syntax_tree.ts
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2019-12-31 18:50:32 +0100
committerAleksey Kladov <aleksey.kladov@gmail.com>2019-12-31 18:50:32 +0100
commitcb41ffbbbdea66d3a0abae4d270da1224a5de91c (patch)
tree40582f9bb4331676a0a469b728a5e6cfe1df5300 /editors/code/src/commands/syntax_tree.ts
parent6368b40dd98b208da3758d4d1eed34cf276e3b09 (diff)
downloadrust-cb41ffbbbdea66d3a0abae4d270da1224a5de91c.tar.gz
rust-cb41ffbbbdea66d3a0abae4d270da1224a5de91c.zip
Fix NPEs
Diffstat (limited to 'editors/code/src/commands/syntax_tree.ts')
-rw-r--r--editors/code/src/commands/syntax_tree.ts9
1 files changed, 4 insertions, 5 deletions
diff --git a/editors/code/src/commands/syntax_tree.ts b/editors/code/src/commands/syntax_tree.ts
index 5b8f6e4d94b..2ee80f910cd 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<string> {
         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<string>(
+        return client.sendRequest<string>(
             'rust-analyzer/syntaxTree',
             request,
         );