@@ -9,29 +9,12 @@ import { Uri, Disposable, SCMProvider, SCMResource, SCMResourceDecorations, SCMR
99import { Model } from './model' ;
1010import * as path from 'path' ;
1111
12- enum Theme {
13- Light ,
14- Dark
15- }
16-
1712const iconsRootPath = path . join ( path . dirname ( __dirname ) , 'resources' , 'icons' ) ;
1813
19- function getIconUri ( iconName : string , theme : Theme ) : Uri {
20- const themeName = theme === Theme . Light ? 'light' : 'dark' ;
21- return Uri . file ( path . join ( iconsRootPath , themeName , `${ iconName } .svg` ) ) ;
14+ function getIconUri ( iconName : string , theme : string ) : Uri {
15+ return Uri . file ( path . join ( iconsRootPath , theme , `${ iconName } .svg` ) ) ;
2216}
2317
24- const Icons = {
25- Modified : getIconUri ( 'status-modified' , Theme . Light ) ,
26- Added : getIconUri ( 'status-added' , Theme . Light ) ,
27- Deleted : getIconUri ( 'status-deleted' , Theme . Light ) ,
28- Renamed : getIconUri ( 'status-renamed' , Theme . Light ) ,
29- Copied : getIconUri ( 'status-copied' , Theme . Light ) ,
30- Untracked : getIconUri ( 'status-untracked' , Theme . Light ) ,
31- Ignored : getIconUri ( 'status-ignored' , Theme . Light ) ,
32- Conflict : getIconUri ( 'status-conflict' , Theme . Light ) ,
33- } ;
34-
3518enum Status {
3619 INDEX_MODIFIED ,
3720 INDEX_ADDED ,
@@ -57,24 +40,47 @@ class Resource implements SCMResource {
5740
5841 get uri ( ) : Uri { return this . _uri ; }
5942
60- private get iconPath ( ) : Uri | undefined {
43+ private static Icons = {
44+ light : {
45+ Modified : getIconUri ( 'status-modified' , 'light' ) ,
46+ Added : getIconUri ( 'status-added' , 'light' ) ,
47+ Deleted : getIconUri ( 'status-deleted' , 'light' ) ,
48+ Renamed : getIconUri ( 'status-renamed' , 'light' ) ,
49+ Copied : getIconUri ( 'status-copied' , 'light' ) ,
50+ Untracked : getIconUri ( 'status-untracked' , 'light' ) ,
51+ Ignored : getIconUri ( 'status-ignored' , 'light' ) ,
52+ Conflict : getIconUri ( 'status-conflict' , 'light' ) ,
53+ } ,
54+ dark : {
55+ Modified : getIconUri ( 'status-modified' , 'dark' ) ,
56+ Added : getIconUri ( 'status-added' , 'dark' ) ,
57+ Deleted : getIconUri ( 'status-deleted' , 'dark' ) ,
58+ Renamed : getIconUri ( 'status-renamed' , 'dark' ) ,
59+ Copied : getIconUri ( 'status-copied' , 'dark' ) ,
60+ Untracked : getIconUri ( 'status-untracked' , 'dark' ) ,
61+ Ignored : getIconUri ( 'status-ignored' , 'dark' ) ,
62+ Conflict : getIconUri ( 'status-conflict' , 'dark' )
63+ }
64+ } ;
65+
66+ private getIconPath ( theme : string ) : Uri | undefined {
6167 switch ( this . type ) {
62- case Status . INDEX_MODIFIED : return Icons . Modified ;
63- case Status . MODIFIED : return Icons . Modified ;
64- case Status . INDEX_ADDED : return Icons . Added ;
65- case Status . INDEX_DELETED : return Icons . Deleted ;
66- case Status . DELETED : return Icons . Deleted ;
67- case Status . INDEX_RENAMED : return Icons . Renamed ;
68- case Status . INDEX_COPIED : return Icons . Copied ;
69- case Status . UNTRACKED : return Icons . Untracked ;
70- case Status . IGNORED : return Icons . Ignored ;
71- case Status . BOTH_DELETED : return Icons . Conflict ;
72- case Status . ADDED_BY_US : return Icons . Conflict ;
73- case Status . DELETED_BY_THEM : return Icons . Conflict ;
74- case Status . ADDED_BY_THEM : return Icons . Conflict ;
75- case Status . DELETED_BY_US : return Icons . Conflict ;
76- case Status . BOTH_ADDED : return Icons . Conflict ;
77- case Status . BOTH_MODIFIED : return Icons . Conflict ;
68+ case Status . INDEX_MODIFIED : return Resource . Icons [ theme ] . Modified ;
69+ case Status . MODIFIED : return Resource . Icons [ theme ] . Modified ;
70+ case Status . INDEX_ADDED : return Resource . Icons [ theme ] . Added ;
71+ case Status . INDEX_DELETED : return Resource . Icons [ theme ] . Deleted ;
72+ case Status . DELETED : return Resource . Icons [ theme ] . Deleted ;
73+ case Status . INDEX_RENAMED : return Resource . Icons [ theme ] . Renamed ;
74+ case Status . INDEX_COPIED : return Resource . Icons [ theme ] . Copied ;
75+ case Status . UNTRACKED : return Resource . Icons [ theme ] . Untracked ;
76+ case Status . IGNORED : return Resource . Icons [ theme ] . Ignored ;
77+ case Status . BOTH_DELETED : return Resource . Icons [ theme ] . Conflict ;
78+ case Status . ADDED_BY_US : return Resource . Icons [ theme ] . Conflict ;
79+ case Status . DELETED_BY_THEM : return Resource . Icons [ theme ] . Conflict ;
80+ case Status . ADDED_BY_THEM : return Resource . Icons [ theme ] . Conflict ;
81+ case Status . DELETED_BY_US : return Resource . Icons [ theme ] . Conflict ;
82+ case Status . BOTH_ADDED : return Resource . Icons [ theme ] . Conflict ;
83+ case Status . BOTH_MODIFIED : return Resource . Icons [ theme ] . Conflict ;
7884 default : return void 0 ;
7985 }
8086 }
@@ -92,10 +98,10 @@ class Resource implements SCMResource {
9298 }
9399
94100 get decorations ( ) : SCMResourceDecorations {
95- return {
96- iconPath : this . iconPath ,
97- strikeThrough : this . strikeThrough
98- } ;
101+ const light = { iconPath : this . getIconPath ( 'light' ) } ;
102+ const dark = { iconPath : this . getIconPath ( 'dark' ) } ;
103+
104+ return { strikeThrough : this . strikeThrough , light , dark } ;
99105 }
100106
101107 constructor ( private _uri : Uri , private type : any ) {
0 commit comments