aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-03-15 17:50:20 +0000
committerGitHub <[email protected]>2021-03-15 17:50:20 +0000
commitd38fd77845c40c6f07507c5c436af903a452efbd (patch)
tree7921f1e3b8811ae9af2bde20fd73c6ee69f23d2e /editors
parent1f28345b37130659438a8d2427f8879a19a14ae9 (diff)
parentf05fef70638f4f66be6681a87be5a8d24b29b0cf (diff)
Merge #8028
8028: Return multiple modules in `parent_module` feature r=matklad a=Veykril Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'editors')
-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