@@ -62,8 +62,8 @@ export class GitTimelineProvider implements TimelineProvider {
6262 this . _repo = repo ;
6363 this . _repoStatusDate = new Date ( ) ;
6464 this . _repoDisposable = Disposable . from (
65- repo . onDidChangeRepository ( this . onRepositoryChanged , this ) ,
66- repo . onDidRunGitStatus ( this . onRepositoryStatusChanged , this )
65+ repo . onDidChangeRepository ( uri => this . onRepositoryChanged ( repo , uri ) ) ,
66+ repo . onDidRunGitStatus ( ( ) => this . onRepositoryStatusChanged ( repo ) )
6767 ) ;
6868 }
6969
@@ -90,7 +90,7 @@ export class GitTimelineProvider implements TimelineProvider {
9090 item . command = {
9191 title : 'Open Diff' ,
9292 command : 'git.openDiff' ,
93- arguments : [ uri , c . hash ]
93+ arguments : [ uri , ` ${ c . hash } ^` , c . hash ]
9494 } ;
9595
9696 return item ;
@@ -124,15 +124,58 @@ export class GitTimelineProvider implements TimelineProvider {
124124 }
125125
126126 const item = new TimelineItem ( 'Staged Changes' , date . getTime ( ) ) ;
127- item . id = '~ ' ;
127+ item . id = 'index ' ;
128128 // TODO[ECA]: Replace with a better icon -- reflecting its status maybe?
129129 item . iconPath = new ( ThemeIcon as any ) ( 'git-commit' ) ;
130130 item . description = `${ dateFormatter . fromNow ( ) } \u2022 You` ;
131131 item . detail = `You \u2014 Index\n${ dateFormatter . fromNow ( ) } (${ dateFormatter . format ( 'MMMM Do, YYYY h:mma' ) } )\n${ status } ` ;
132132 item . command = {
133133 title : 'Open Comparison' ,
134134 command : 'git.openDiff' ,
135- arguments : [ uri , '~' ]
135+ arguments : [ uri , 'HEAD' , '~' ]
136+ } ;
137+
138+ items . push ( item ) ;
139+ }
140+
141+
142+ const working = repo . workingTreeGroup . resourceStates . find ( r => r . resourceUri . fsPath === uri . fsPath ) ;
143+ if ( working ) {
144+ const date = new Date ( ) ;
145+ dateFormatter = dayjs ( date ) ;
146+
147+ let status ;
148+ switch ( working . type ) {
149+ case Status . INDEX_MODIFIED :
150+ status = 'Modified' ;
151+ break ;
152+ case Status . INDEX_ADDED :
153+ status = 'Added' ;
154+ break ;
155+ case Status . INDEX_DELETED :
156+ status = 'Deleted' ;
157+ break ;
158+ case Status . INDEX_RENAMED :
159+ status = 'Renamed' ;
160+ break ;
161+ case Status . INDEX_COPIED :
162+ status = 'Copied' ;
163+ break ;
164+ default :
165+ status = '' ;
166+ break ;
167+ }
168+
169+ const item = new TimelineItem ( 'Uncommited Changes' , date . getTime ( ) ) ;
170+ item . id = 'working' ;
171+ // TODO[ECA]: Replace with a better icon -- reflecting its status maybe?
172+ item . iconPath = new ( ThemeIcon as any ) ( 'git-commit' ) ;
173+ item . description = `${ dateFormatter . fromNow ( ) } \u2022 You` ;
174+ item . detail = `You \u2014 Working Tree\n${ dateFormatter . fromNow ( ) } (${ dateFormatter . format ( 'MMMM Do, YYYY h:mma' ) } )\n${ status } ` ;
175+ item . command = {
176+ title : 'Open Comparison' ,
177+ command : 'git.openDiff' ,
178+ arguments : [ uri , index ? '~' : 'HEAD' , '' ]
136179 } ;
137180
138181 items . push ( item ) ;
@@ -141,23 +184,30 @@ export class GitTimelineProvider implements TimelineProvider {
141184 return items ;
142185 }
143186
144- @debounce ( 500 )
145187 private onRepositoriesChanged ( _repo : Repository ) {
146188 // console.log(`GitTimelineProvider.onRepositoriesChanged`);
147189
148190 // TODO[ECA]: Being naive for now and just always refreshing each time there is a new repository
149- this . _onDidChange . fire ( ) ;
191+ this . fireChanged ( ) ;
150192 }
151193
152- @debounce ( 500 )
153- private onRepositoryChanged ( ) {
154- // console.log(`GitTimelineProvider.onRepositoryChanged`);
194+ private onRepositoryChanged ( _repo : Repository , _uri : Uri ) {
195+ // console.log(`GitTimelineProvider.onRepositoryChanged: uri=${uri.toString(true)}`);
155196
156- this . _onDidChange . fire ( ) ;
197+ this . fireChanged ( ) ;
157198 }
158199
159- private onRepositoryStatusChanged ( ) {
200+ private onRepositoryStatusChanged ( _repo : Repository ) {
201+ // console.log(`GitTimelineProvider.onRepositoryStatusChanged`);
202+
160203 // This is crappy, but for now just save the last time a status was run and use that as the timestamp for staged items
161204 this . _repoStatusDate = new Date ( ) ;
205+
206+ this . fireChanged ( ) ;
207+ }
208+
209+ @debounce ( 500 )
210+ private fireChanged ( ) {
211+ this . _onDidChange . fire ( ) ;
162212 }
163213}
0 commit comments