Skip to content

Commit 380de2f

Browse files
authored
Git - render emojis when showing blame information (microsoft#236051)
1 parent af33df9 commit 380de2f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

extensions/git/src/blame.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Repository } from './repository';
1010
import { throttle } from './decorators';
1111
import { BlameInformation } from './git';
1212
import { fromGitUri, isGitUri } from './uri';
13+
import { emojify, ensureEmojis } from './emoji';
1314

1415
function lineRangesContainLine(changes: readonly TextEditorChange[], lineNumber: number): boolean {
1516
return changes.some(c => c.modified.startLineNumber <= lineNumber && lineNumber < c.modified.endLineNumberExclusive);
@@ -171,7 +172,7 @@ export class GitBlameController {
171172
const templateTokens = {
172173
hash: blameInformation.hash,
173174
hashShort: blameInformation.hash.substring(0, 8),
174-
subject: blameInformation.subject ?? '',
175+
subject: emojify(blameInformation.subject ?? ''),
175176
authorName: blameInformation.authorName ?? '',
176177
authorEmail: blameInformation.authorEmail ?? '',
177178
authorDate: new Date(blameInformation.authorDate ?? new Date()).toLocaleString(),
@@ -203,7 +204,7 @@ export class GitBlameController {
203204
markdownString.appendMarkdown('\n\n');
204205
}
205206

206-
markdownString.appendMarkdown(`${blameInformation.subject}\n\n`);
207+
markdownString.appendMarkdown(`${emojify(blameInformation.subject ?? '')}\n\n`);
207208
markdownString.appendMarkdown(`---\n\n`);
208209

209210
markdownString.appendMarkdown(`[$(eye) View Commit](command:git.blameStatusBarItem.viewCommit?${encodeURIComponent(JSON.stringify([documentUri, blameInformation.hash]))} "${l10n.t('View Commit')}")`);
@@ -259,6 +260,10 @@ export class GitBlameController {
259260
return resourceBlameInformation;
260261
}
261262

263+
// Ensure that the emojis are loaded. We will
264+
// use them when formatting the blame information.
265+
await ensureEmojis();
266+
262267
// Get blame information for the resource and cache it
263268
const blameInformation = await repository.blame2(resource.fsPath, commit) ?? [];
264269
this._repositoryBlameCache.setBlameInformation(repository, resource, commit, blameInformation);

0 commit comments

Comments
 (0)