diff --git a/extensions/references-view/src/calls/model.ts b/extensions/references-view/src/calls/model.ts index ce8cbbcf973..30d320355aa 100644 --- a/extensions/references-view/src/calls/model.ts +++ b/extensions/references-view/src/calls/model.ts @@ -180,13 +180,34 @@ class CallItemDataProvider implements vscode.TreeDataProvider { item.tooltip = item.label ? `${item.label} - ${element.item.detail}` : element.item.detail; item.contextValue = 'call-item'; item.iconPath = getThemeIcon(element.item.kind); + + type OpenArgs = [vscode.Uri, vscode.TextDocumentShowOptions]; + let openArgs: OpenArgs; + + if (element.model.direction === CallsDirection.Outgoing) { + + openArgs = [element.item.uri, { selection: element.item.selectionRange.with({ end: element.item.selectionRange.start }) }]; + + } else { + // incoming call -> reveal first call instead of caller + let firstLoctionStart: vscode.Position | undefined; + if (element.locations) { + for (const loc of element.locations) { + if (loc.uri.toString() === element.item.uri.toString()) { + firstLoctionStart = firstLoctionStart?.isBefore(loc.range.start) ? firstLoctionStart : loc.range.start; + } + } + } + if (!firstLoctionStart) { + firstLoctionStart = element.item.selectionRange.start; + } + openArgs = [element.item.uri, { selection: new vscode.Range(firstLoctionStart, firstLoctionStart) }]; + } + item.command = { command: 'vscode.open', title: vscode.l10n.t('Open Call'), - arguments: [ - element.item.uri, - { selection: element.item.selectionRange.with({ end: element.item.selectionRange.start }) } - ] + arguments: openArgs }; item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; return item;