Johannes Rieken 2022-12-07 15:22:52 +01:00 committed by GitHub
parent 9d1c2920c0
commit 386459dec0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -180,13 +180,34 @@ class CallItemDataProvider implements vscode.TreeDataProvider<CallItem> {
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,
<vscode.TextDocumentShowOptions>{ selection: element.item.selectionRange.with({ end: element.item.selectionRange.start }) }
]
arguments: openArgs
};
item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed;
return item;