@@ -100,6 +100,7 @@ import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity'
100100import { EditOperation } from 'vs/editor/common/core/editOperation' ;
101101import { stripIcons } from 'vs/base/common/iconLabels' ;
102102import { IconLabel } from 'vs/base/browser/ui/iconLabel/iconLabel' ;
103+ import { registerColor , transparent } from 'vs/platform/theme/common/colorRegistry' ;
103104
104105// type SCMResourceTreeNode = IResourceNode<ISCMResource, ISCMResourceGroup>;
105106// type SCMHistoryItemChangeResourceTreeNode = IResourceNode<SCMHistoryItemChangeTreeElement, SCMHistoryItemTreeElement>;
@@ -116,6 +117,28 @@ type TreeElement =
116117 IResourceNode < SCMHistoryItemChangeTreeElement , SCMHistoryItemTreeElement > |
117118 SCMViewSeparatorElement ;
118119
120+ registerColor ( 'scm.historyItemAdditionsForeground' , {
121+ dark : 'gitDecoration.addedResourceForeground' ,
122+ light : 'gitDecoration.addedResourceForeground' ,
123+ hcDark : 'gitDecoration.addedResourceForeground' ,
124+ hcLight : 'gitDecoration.addedResourceForeground'
125+ } , localize ( 'scm.historyItemAdditionsForeground' , "History item additions foreground color." ) ) ;
126+
127+ registerColor ( 'scm.historyItemDeletionsForeground' , {
128+ dark : 'gitDecoration.deletedResourceForeground' ,
129+ light : 'gitDecoration.deletedResourceForeground' ,
130+ hcDark : 'gitDecoration.deletedResourceForeground' ,
131+ hcLight : 'gitDecoration.deletedResourceForeground'
132+ } , localize ( 'scm.historyItemDeletionsForeground' , "History item deletions foreground color." ) ) ;
133+
134+ registerColor ( 'scm.historyItemStatisticsBorder' , {
135+ dark : transparent ( 'foreground' , 0.1 ) ,
136+ light : transparent ( 'foreground' , 0.1 ) ,
137+ hcDark : transparent ( 'foreground' , 0.1 ) ,
138+ hcLight : transparent ( 'foreground' , 0.1 )
139+ } , localize ( 'scm.historyItemStatisticsBorder' , "History item statistics border color." ) ) ;
140+
141+
119142interface ISCMLayout {
120143 height : number | undefined ;
121144 width : number | undefined ;
@@ -735,7 +758,9 @@ interface HistoryItemTemplate {
735758 readonly iconContainer : HTMLElement ;
736759 readonly label : IconLabel ;
737760 readonly statsContainer : HTMLElement ;
738- readonly statsLabel : IconLabel ;
761+ readonly filesLabel : HTMLElement ;
762+ readonly insertionsLabel : HTMLElement ;
763+ readonly deletionsLabel : HTMLElement ;
739764 readonly actionBar : ActionBar ;
740765 readonly elementDisposables : DisposableStore ;
741766 readonly disposables : IDisposable ;
@@ -765,9 +790,11 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer<SCMHistoryItemTre
765790 disposables . add ( actionBar ) ;
766791
767792 const statsContainer = append ( element , $ ( '.stats-container' ) ) ;
768- const statsLabel = new IconLabel ( statsContainer , { supportIcons : true } ) ;
793+ const filesLabel = append ( statsContainer , $ ( '.files-label' ) ) ;
794+ const insertionsLabel = append ( statsContainer , $ ( '.insertions-label' ) ) ;
795+ const deletionsLabel = append ( statsContainer , $ ( '.deletions-label' ) ) ;
769796
770- return { iconContainer, label : iconLabel , actionBar, statsContainer, statsLabel , elementDisposables : new DisposableStore ( ) , disposables } ;
797+ return { iconContainer, label : iconLabel , actionBar, statsContainer, filesLabel , insertionsLabel , deletionsLabel , elementDisposables : new DisposableStore ( ) , disposables } ;
771798 }
772799
773800 renderElement ( node : ITreeNode < SCMHistoryItemTreeElement , void > , index : number , templateData : HistoryItemTemplate , height : number | undefined ) : void {
@@ -798,32 +825,35 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer<SCMHistoryItemTre
798825 private renderStatistics ( node : ITreeNode < SCMHistoryItemTreeElement , void > , index : number , templateData : HistoryItemTemplate , height : number | undefined ) : void {
799826 const historyItem = node . element ;
800827
801- if ( historyItem . statistics ?. files || historyItem . statistics ?. insertions || historyItem . statistics ?. deletions ) {
802- const statsLabelTitle : string [ ] = [ ] ;
803-
804- const filesLabel = historyItem . statistics ?. files ? `${ historyItem . statistics . files } $(files)` : '' ;
805- const insertionsLabel = historyItem . statistics ?. insertions ? ` ${ historyItem . statistics . insertions } $(diff-added)` : '' ;
806- const deletionsLabel = historyItem . statistics ?. deletions ? ` ${ historyItem . statistics . deletions } $(diff-removed)` : '' ;
828+ if ( historyItem . statistics ) {
829+ const statsAriaLabel : string [ ] = [ ] ;
807830
808831 if ( historyItem . statistics ?. files ) {
809832 const filesDescription = historyItem . statistics . files === 1 ?
810833 localize ( 'fileChanged' , "file changed" ) : localize ( 'filesChanged' , "files changed" ) ;
811- statsLabelTitle . push ( `${ historyItem . statistics . files } ${ filesDescription } ` ) ;
834+ statsAriaLabel . push ( `${ historyItem . statistics . files } ${ filesDescription } ` ) ;
812835 }
813836
814837 if ( historyItem . statistics ?. insertions ) {
815838 const insertionsDescription = historyItem . statistics . insertions === 1 ?
816839 localize ( 'insertion' , "insertion{0}" , '(+)' ) : localize ( 'insertions' , "insertions{0}" , '(+)' ) ;
817- statsLabelTitle . push ( `${ historyItem . statistics . insertions } ${ insertionsDescription } ` ) ;
840+ statsAriaLabel . push ( `${ historyItem . statistics . insertions } ${ insertionsDescription } ` ) ;
818841 }
819842
820843 if ( historyItem . statistics ?. deletions ) {
821844 const deletionsDescription = historyItem . statistics . deletions === 1 ?
822845 localize ( 'deletion' , "deletion{0}" , '(-)' ) : localize ( 'deletions' , "deletions{0}" , '(-)' ) ;
823- statsLabelTitle . push ( `${ historyItem . statistics . deletions } ${ deletionsDescription } ` ) ;
846+ statsAriaLabel . push ( `${ historyItem . statistics . deletions } ${ deletionsDescription } ` ) ;
824847 }
825848
826- templateData . statsLabel . setLabel ( `${ filesLabel } ${ insertionsLabel } ${ deletionsLabel } ` , undefined , { title : statsLabelTitle . join ( ', ' ) } ) ;
849+ const statsTitle = statsAriaLabel . join ( ', ' ) ;
850+ templateData . statsContainer . title = statsTitle ;
851+ templateData . statsContainer . setAttribute ( 'aria-label' , statsTitle ) ;
852+
853+ templateData . filesLabel . textContent = historyItem . statistics . files > 0 ? historyItem . statistics . files . toString ( ) : '' ;
854+ templateData . insertionsLabel . textContent = historyItem . statistics . insertions > 0 ? `+${ historyItem . statistics . insertions } ` : '' ;
855+ templateData . deletionsLabel . textContent = historyItem . statistics . deletions > 0 ? `-${ historyItem . statistics . deletions } ` : '' ;
856+
827857 templateData . statsContainer . style . display = '' ;
828858 } else {
829859 templateData . statsContainer . style . display = 'none' ;
0 commit comments