aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
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