aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-03-15 14:49:20 +0000
committerLukas Wirth <[email protected]>2021-03-15 14:50:55 +0000
commitf05fef70638f4f66be6681a87be5a8d24b29b0cf (patch)
treeb5e116dcc43081f51fbc079c0ec0cb9fd3c644c5 /editors/code
parent2e3c156b0e560c4ef7075955883f30e517bdd075 (diff)
Support multiple parents in parentModule in vscode-client
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/src/commands.ts24
1 files changed, 15 insertions, 9 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index 694f445bc..bed1f0116 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -170,22 +170,28 @@ export function parentModule(ctx: Ctx): Cmd {
170 const client = ctx.client; 170 const client = ctx.client;
171 if (!editor || !client) return; 171 if (!editor || !client) return;
172 172
173 const response = await client.sendRequest(ra.parentModule, { 173 const locations = await client.sendRequest(ra.parentModule, {
174 textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), 174 textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document),
175 position: client.code2ProtocolConverter.asPosition( 175 position: client.code2ProtocolConverter.asPosition(
176 editor.selection.active, 176 editor.selection.active,
177 ), 177 ),
178 }); 178 });
179 const loc = response[0];
180 if (!loc) return;
181 179
182 const uri = client.protocol2CodeConverter.asUri(loc.targetUri); 180 if (locations.length === 1) {
183 const range = client.protocol2CodeConverter.asRange(loc.targetRange); 181 const loc = locations[0];
184 182
185 const doc = await vscode.workspace.openTextDocument(uri); 183 const uri = client.protocol2CodeConverter.asUri(loc.targetUri);
186 const e = await vscode.window.showTextDocument(doc); 184 const range = client.protocol2CodeConverter.asRange(loc.targetRange);
187 e.selection = new vscode.Selection(range.start, range.start); 185
188 e.revealRange(range, vscode.TextEditorRevealType.InCenter); 186 const doc = await vscode.workspace.openTextDocument(uri);
187 const e = await vscode.window.showTextDocument(doc);
188 e.selection = new vscode.Selection(range.start, range.start);
189 e.revealRange(range, vscode.TextEditorRevealType.InCenter);
190 } else {
191 const uri = editor.document.uri.toString();
192 const position = client.code2ProtocolConverter.asPosition(editor.selection.active);
193 await showReferencesImpl(client, uri, position, locations.map(loc => lc.Location.create(loc.targetUri, loc.targetRange)));
194 }
189 }; 195 };
190} 196}
191 197