mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-13 04:32:43 +01:00
SCM - add history item hover (#209373)
This commit is contained in:
@@ -106,8 +106,9 @@ import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import { DropdownWithPrimaryActionViewItem } from 'vs/platform/actions/browser/dropdownWithPrimaryActionViewItem';
|
||||
import { clamp } from 'vs/base/common/numbers';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
|
||||
import { ICustomHover, ITooltipMarkdownString, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
|
||||
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
|
||||
import { MarkdownString } from 'vs/base/common/htmlContent';
|
||||
|
||||
// type SCMResourceTreeNode = IResourceNode<ISCMResource, ISCMResourceGroup>;
|
||||
// type SCMHistoryItemChangeResourceTreeNode = IResourceNode<SCMHistoryItemChangeTreeElement, SCMHistoryItemTreeElement>;
|
||||
@@ -945,8 +946,9 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer<SCMHistoryItemTre
|
||||
templateData.iconContainer.classList.add(...ThemeIcon.asClassNameArray(historyItem.icon));
|
||||
}
|
||||
|
||||
const title = this.getTooltip(historyItem);
|
||||
const [matches, descriptionMatches] = this.processMatches(historyItem, node.filterData);
|
||||
templateData.label.setLabel(historyItem.message, historyItem.author, { matches, descriptionMatches });
|
||||
templateData.label.setLabel(historyItem.message, historyItem.author, { matches, descriptionMatches, title });
|
||||
|
||||
templateData.actionBar.clear();
|
||||
templateData.actionBar.context = historyItem;
|
||||
@@ -964,6 +966,23 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer<SCMHistoryItemTre
|
||||
throw new Error('Should never happen since node is incompressible');
|
||||
}
|
||||
|
||||
private getTooltip(historyItem: SCMHistoryItemTreeElement): ITooltipMarkdownString {
|
||||
const markdown = new MarkdownString('', { isTrusted: true, supportThemeIcons: true });
|
||||
|
||||
if (historyItem.author) {
|
||||
markdown.appendMarkdown(`$(account) **${historyItem.author}**\n\n`);
|
||||
}
|
||||
|
||||
if (historyItem.timestamp) {
|
||||
const dateFormatter = new Intl.DateTimeFormat(platform.language, { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric' });
|
||||
markdown.appendMarkdown(`$(history) ${dateFormatter.format(historyItem.timestamp)}\n\n`);
|
||||
}
|
||||
|
||||
markdown.appendMarkdown(historyItem.message);
|
||||
|
||||
return { markdown, markdownNotSupportedFallback: historyItem.message };
|
||||
}
|
||||
|
||||
private processMatches(historyItem: SCMHistoryItemTreeElement, filterData: LabelFuzzyScore | undefined): [IMatch[] | undefined, IMatch[] | undefined] {
|
||||
if (!filterData) {
|
||||
return [undefined, undefined];
|
||||
|
||||
Reference in New Issue
Block a user