@@ -29,6 +29,51 @@ export class LineHistoryNode extends SubscribeableViewNode {
2929 CommitFileNodeDisplayAs . CommitLabel |
3030 ( this . view . config . avatars ? CommitFileNodeDisplayAs . Gravatar : CommitFileNodeDisplayAs . StatusIcon ) ;
3131
32+ if ( this . uri . sha === undefined ) {
33+ // Check for any uncommitted changes in the range
34+ const blame = await Container . git . getBlameForRange ( this . uri , this . selection ) ;
35+ if ( blame !== undefined ) {
36+ for ( const commit of blame . commits . values ( ) ) {
37+ if ( ! commit . isUncommitted ) continue ;
38+
39+ const file : GitFile = {
40+ fileName : commit . fileName ,
41+ indexStatus : '?' ,
42+ originalFileName : commit . originalFileName ,
43+ repoPath : this . uri . repoPath ! ,
44+ status : 'M' ,
45+ workingTreeStatus : '?'
46+ } ;
47+
48+ const uncommitted = new GitLogCommit (
49+ GitCommitType . File ,
50+ this . uri . repoPath ! ,
51+ commit . sha ,
52+ 'You' ,
53+ commit . email ,
54+ commit . date ,
55+ // TODO: Add committed date to blame?
56+ commit . date ,
57+ commit . message ,
58+ commit . fileName ,
59+ [ file ] ,
60+ 'M' ,
61+ commit . originalFileName ,
62+ commit . previousSha ,
63+ commit . originalFileName || commit . fileName
64+ ) ;
65+
66+ children . splice (
67+ 0 ,
68+ 0 ,
69+ new CommitFileNode ( this . view , this , file , uncommitted , displayAs , this . selection )
70+ ) ;
71+
72+ break ;
73+ }
74+ }
75+ }
76+
3277 const log = await Container . git . getLogForFile ( this . uri . repoPath , this . uri . fsPath , {
3378 ref : this . uri . sha ,
3479 range : this . selection
@@ -45,45 +90,6 @@ export class LineHistoryNode extends SubscribeableViewNode {
4590 ) ;
4691 }
4792
48- const blame = await Container . git . getBlameForLine ( this . uri , this . selection . active . line ) ;
49- if ( blame !== undefined ) {
50- let first = children [ 0 ] as CommitFileNode | undefined ;
51- if ( first !== undefined && ! ( first instanceof CommitFileNode ) ) {
52- first = children [ 1 ] as CommitFileNode | undefined ;
53- }
54-
55- if ( first === undefined || first . commit . sha !== blame . commit . sha ) {
56- const file : GitFile = {
57- fileName : blame . commit . fileName ,
58- indexStatus : '?' ,
59- originalFileName : blame . commit . originalFileName ,
60- repoPath : this . uri . repoPath ! ,
61- status : 'M' ,
62- workingTreeStatus : '?'
63- } ;
64-
65- const commit = new GitLogCommit (
66- GitCommitType . File ,
67- this . uri . repoPath ! ,
68- blame . commit . sha ,
69- 'You' ,
70- blame . commit . email ,
71- blame . commit . date ,
72- // TODO: Add committed date to blame?
73- blame . commit . date ,
74- blame . commit . message ,
75- blame . commit . fileName ,
76- [ file ] ,
77- 'M' ,
78- blame . commit . originalFileName ,
79- blame . commit . previousSha ,
80- blame . commit . originalFileName || blame . commit . fileName
81- ) ;
82-
83- children . splice ( 0 , 0 , new CommitFileNode ( this . view , this , file , commit , displayAs , this . selection ) ) ;
84- }
85- }
86-
8793 if ( children . length === 0 ) return [ new MessageNode ( this . view , this , 'No line history could be found.' ) ] ;
8894 return children ;
8995 }
0 commit comments