mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-23 03:44:23 +00:00
Fix NPEs
This commit is contained in:
parent
6368b40dd9
commit
cb41ffbbbd
5 changed files with 24 additions and 21 deletions
|
@ -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,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue