Git - improve graph/timeline/blame hover rendering (#273932)

This commit is contained in:
Ladislau Szomoru
2025-10-29 13:14:58 +01:00
committed by GitHub
parent 42dab51b3b
commit 8fb6a9c257

View File

@@ -639,28 +639,47 @@ export function getHistoryItemHover(authorAvatar: string | undefined, authorName
enabledCommands: commands?.flat().map(c => c.command) ?? []
};
// Author
if (authorName) {
const avatar = authorAvatar ? `![${authorName}](${authorAvatar}|width=${AVATAR_SIZE},height=${AVATAR_SIZE})` : '$(account)';
if (authorEmail) {
const emailTitle = l10n.t('Email');
markdownString.appendMarkdown(`${avatar} [**${authorName}**](mailto:${authorEmail} "${emailTitle} ${authorName}")`);
// Avatar
if (authorAvatar) {
markdownString.appendMarkdown('![');
markdownString.appendText(authorName);
markdownString.appendMarkdown('](');
markdownString.appendText(authorAvatar);
markdownString.appendMarkdown(`|width=${AVATAR_SIZE},height=${AVATAR_SIZE})`);
} else {
markdownString.appendMarkdown(`${avatar} **${authorName}**`);
markdownString.appendMarkdown('$(account)');
}
if (authorDate) {
// Email
if (authorEmail) {
markdownString.appendMarkdown(' [**');
markdownString.appendText(authorName);
markdownString.appendMarkdown('**](mailto:');
markdownString.appendText(authorEmail);
markdownString.appendMarkdown(')');
} else {
markdownString.appendMarkdown(' **');
markdownString.appendText(authorName);
markdownString.appendMarkdown('**');
}
// Date
if (authorDate && !isNaN(new Date(authorDate).getTime())) {
const dateString = new Date(authorDate).toLocaleString(undefined, {
year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric'
});
markdownString.appendMarkdown(`, $(history) ${fromNow(authorDate, true, true)} (${dateString})`);
markdownString.appendMarkdown(', $(history)');
markdownString.appendText(` ${fromNow(authorDate, true, true)} (${dateString})`);
}
markdownString.appendMarkdown('\n\n');
}
// Subject | Message
markdownString.appendMarkdown(`${emojify(message.replace(/\r\n|\r|\n/g, '\n\n'))}\n\n`);
// Subject | Message (escape image syntax)
markdownString.appendMarkdown(`${emojify(message.replace(/!\[/g, '![').replace(/\r\n|\r|\n/g, '\n\n'))}\n\n`);
markdownString.appendMarkdown(`---\n\n`);
// Short stats