From e8ce9b3b29f397fe343f49df9cf160bd6f59cd79 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Fri, 10 Nov 2023 09:26:54 +0100 Subject: [PATCH] SCM - fix statistics tooltip localization (#197896) --- .../contrib/scm/browser/scmViewPane.ts | 60 ++++++++----------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts index c451a544065..5e07c6e6bd5 100644 --- a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts +++ b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts @@ -733,12 +733,9 @@ class HistoryItemGroupRenderer implements ICompressibleTreeRenderer, index: number, templateData: HistoryItemTemplate, height: number | undefined): void { @@ -775,32 +767,38 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer, void>, index: number, templateData: HistoryItemTemplate, height: number | undefined): void { + throw new Error('Should never happen since node is incompressible'); + } + + private renderStatistics(node: ITreeNode, index: number, templateData: HistoryItemTemplate, height: number | undefined): void { + const historyItem = node.element; if (historyItem.statistics?.files || historyItem.statistics?.insertions || historyItem.statistics?.deletions) { const statsLabelTitle: string[] = []; + const filesLabel = historyItem.statistics?.files ? `${historyItem.statistics.files}$(files)` : ''; - if (filesLabel !== '') { - statsLabelTitle.push(`${historyItem.statistics.files} ${historyItem.statistics.files === 1 ? 'file' : 'files'} changed`); - } - const insertionsLabel = historyItem.statistics?.insertions ? ` ${historyItem.statistics.insertions}$(diff-added)` : ''; - if (insertionsLabel !== '') { - statsLabelTitle.push(`${historyItem.statistics.insertions} insertions(+)`); + const deletionsLabel = historyItem.statistics?.deletions ? ` ${historyItem.statistics.deletions}$(diff-removed)` : ''; + + if (historyItem.statistics?.files) { + const filesDescription = historyItem.statistics.files === 1 ? + localize('fileChanged', "file changed") : localize('filesChanged', "files changed"); + statsLabelTitle.push(`${historyItem.statistics.files} ${filesDescription}`); } - const deletionsLabel = historyItem.statistics?.deletions ? ` ${historyItem.statistics.deletions}$(diff-removed)` : ''; - if (deletionsLabel !== '') { - statsLabelTitle.push(`${historyItem.statistics.deletions} deletions(-)`); + if (historyItem.statistics?.insertions) { + const insertionsDescription = localize('insertions', "insertions{0}", '(+)'); + statsLabelTitle.push(`${historyItem.statistics.insertions} ${insertionsDescription}`); + } + + if (historyItem.statistics?.deletions) { + const deletionsDescription = localize('deletions', "deletions{0}", '(-)'); + statsLabelTitle.push(`${historyItem.statistics.deletions} ${deletionsDescription}`); } templateData.statsLabel.setLabel(`${filesLabel}${insertionsLabel}${deletionsLabel}`, undefined, { title: statsLabelTitle.join(', ') }); @@ -808,14 +806,8 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer, void>, index: number, templateData: HistoryItemTemplate, height: number | undefined): void { - throw new Error('Should never happen since node is incompressible'); - } disposeTemplate(templateData: HistoryItemTemplate): void { templateData.disposables.dispose(); }