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/matching_brace.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/matching_brace.ts')
-rw-r--r-- | editors/code/src/commands/matching_brace.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/editors/code/src/commands/matching_brace.ts b/editors/code/src/commands/matching_brace.ts index 59c253f88..7c58bb7e7 100644 --- a/editors/code/src/commands/matching_brace.ts +++ b/editors/code/src/commands/matching_brace.ts | |||
@@ -6,21 +6,21 @@ import { Ctx, Cmd } from '../ctx'; | |||
6 | export function matchingBrace(ctx: Ctx): Cmd { | 6 | export function matchingBrace(ctx: Ctx): Cmd { |
7 | return async () => { | 7 | return async () => { |
8 | const editor = ctx.activeRustEditor; | 8 | const editor = ctx.activeRustEditor; |
9 | if (!editor) { | 9 | const client = ctx.client; |
10 | return; | 10 | if (!editor || !client) return; |
11 | } | 11 | |
12 | const request: FindMatchingBraceParams = { | 12 | const request: FindMatchingBraceParams = { |
13 | textDocument: { uri: editor.document.uri.toString() }, | 13 | textDocument: { uri: editor.document.uri.toString() }, |
14 | offsets: editor.selections.map(s => | 14 | offsets: editor.selections.map(s => |
15 | ctx.client.code2ProtocolConverter.asPosition(s.active), | 15 | client.code2ProtocolConverter.asPosition(s.active), |
16 | ), | 16 | ), |
17 | }; | 17 | }; |
18 | const response = await ctx.client.sendRequest<lc.Position[]>( | 18 | const response = await client.sendRequest<lc.Position[]>( |
19 | 'rust-analyzer/findMatchingBrace', | 19 | 'rust-analyzer/findMatchingBrace', |
20 | request, | 20 | request, |
21 | ); | 21 | ); |
22 | editor.selections = editor.selections.map((sel, idx) => { | 22 | editor.selections = editor.selections.map((sel, idx) => { |
23 | const active = ctx.client.protocol2CodeConverter.asPosition( | 23 | const active = client.protocol2CodeConverter.asPosition( |
24 | response[idx], | 24 | response[idx], |
25 | ); | 25 | ); |
26 | const anchor = sel.isEmpty ? active : sel.anchor; | 26 | const anchor = sel.isEmpty ? active : sel.anchor; |