@@ -43,13 +43,42 @@ export class StatusFilesNode extends ExplorerNode {
4343 }
4444
4545 if ( this . status . files . length !== 0 && this . includeWorkingTree ) {
46- statuses . splice ( 0 , 0 , ...this . status . files . map ( s => {
47- return {
48- ...s ,
49- commit : new GitLogCommit ( GitCommitType . File , repoPath , GitService . uncommittedSha , s . fileName , 'You' , new Date ( ) , '' , s . status , [ s ] , s . originalFileName , 'HEAD' , s . fileName )
50- } as IGitStatusFileWithCommit ;
46+ statuses . splice ( 0 , 0 , ...Iterables . flatMap ( this . status . files , s => {
47+ if ( s . workTreeStatus !== undefined && s . indexStatus !== undefined ) {
48+ // Decrements the date to guarantee this entry will be sorted after the previous entry (most recent first)
49+ const older = new Date ( ) ;
50+ older . setMilliseconds ( older . getMilliseconds ( ) - 1 ) ;
51+
52+ return [
53+ {
54+ ...s ,
55+ commit : new GitLogCommit ( GitCommitType . File , repoPath , GitService . uncommittedSha , s . fileName , 'You' , new Date ( ) , '' , s . status , [ s ] , s . originalFileName , GitService . stagedUncommittedSha , s . fileName )
56+ } as IGitStatusFileWithCommit ,
57+ {
58+ ...s ,
59+ commit : new GitLogCommit ( GitCommitType . File , repoPath , GitService . stagedUncommittedSha , s . fileName , 'You' , older , '' , s . status , [ s ] , s . originalFileName , 'HEAD' , s . fileName )
60+ } as IGitStatusFileWithCommit
61+ ] ;
62+ }
63+ else if ( s . indexStatus !== undefined ) {
64+ return [
65+ {
66+ ...s ,
67+ commit : new GitLogCommit ( GitCommitType . File , repoPath , GitService . stagedUncommittedSha , s . fileName , 'You' , new Date ( ) , '' , s . status , [ s ] , s . originalFileName , 'HEAD' , s . fileName )
68+ } as IGitStatusFileWithCommit
69+ ] ;
70+ }
71+ else {
72+ return [
73+ {
74+ ...s ,
75+ commit : new GitLogCommit ( GitCommitType . File , repoPath , GitService . uncommittedSha , s . fileName , 'You' , new Date ( ) , '' , s . status , [ s ] , s . originalFileName , 'HEAD' , s . fileName )
76+ } as IGitStatusFileWithCommit
77+ ] ;
78+ }
5179 } ) ) ;
5280 }
81+
5382 statuses . sort ( ( a , b ) => b . commit . date . getTime ( ) - a . commit . date . getTime ( ) ) ;
5483
5584 const groups = Arrays . groupBy ( statuses , s => s . fileName ) ;
0 commit comments