@@ -8,25 +8,13 @@ import { CommitFormatter, GitFile, GitLogCommit, GitUri, StatusFileFormatter } f
88import { View } from '../viewBase' ;
99import { ResourceType , ViewNode , ViewRefFileNode } from './viewNode' ;
1010
11- export enum CommitFileNodeDisplayAs {
12- CommitLabel = 1 << 0 ,
13- FileLabel = 1 << 1 ,
14-
15- CommitIcon = 1 << 2 ,
16- StatusIcon = 1 << 3 ,
17- Gravatar = 1 << 4 ,
18-
19- File = FileLabel | StatusIcon
20- }
21-
2211export class CommitFileNode extends ViewRefFileNode {
2312 constructor (
2413 view : View ,
2514 parent : ViewNode ,
2615 public readonly file : GitFile ,
2716 public commit : GitLogCommit ,
28- private readonly _displayAs : CommitFileNodeDisplayAs ,
29- private readonly _selection ?: Selection
17+ private readonly _options : { displayAsCommit ?: boolean ; inFileHistory ?: boolean ; selection ?: Selection } = { }
3018 ) {
3119 super ( GitUri . fromFile ( file , commit . repoPath , commit . sha ) , view , parent ) ;
3220 }
@@ -70,22 +58,16 @@ export class CommitFileNode extends ViewRefFileNode {
7058 item . description = this . description ;
7159 item . tooltip = this . tooltip ;
7260
73- if ( ( this . _displayAs & CommitFileNodeDisplayAs . CommitIcon ) === CommitFileNodeDisplayAs . CommitIcon ) {
74- item . iconPath = {
75- dark : Container . context . asAbsolutePath ( paths . join ( 'images' , 'dark' , 'icon-commit.svg' ) ) ,
76- light : Container . context . asAbsolutePath ( paths . join ( 'images' , 'light' , 'icon-commit.svg' ) )
77- } ;
61+ if ( this . _options . displayAsCommit && this . view . config . avatars ) {
62+ item . iconPath = this . commit . getGravatarUri ( Container . config . defaultGravatarsStyle ) ;
7863 }
79- else if ( ( this . _displayAs & CommitFileNodeDisplayAs . StatusIcon ) === CommitFileNodeDisplayAs . StatusIcon ) {
64+ else {
8065 const icon = GitFile . getStatusIcon ( this . file . status ) ;
8166 item . iconPath = {
8267 dark : Container . context . asAbsolutePath ( paths . join ( 'images' , 'dark' , icon ) ) ,
8368 light : Container . context . asAbsolutePath ( paths . join ( 'images' , 'light' , icon ) )
8469 } ;
8570 }
86- else if ( ( this . _displayAs & CommitFileNodeDisplayAs . Gravatar ) === CommitFileNodeDisplayAs . Gravatar ) {
87- item . iconPath = this . commit . getGravatarUri ( Container . config . defaultGravatarsStyle ) ;
88- }
8971
9072 item . command = this . getCommand ( ) ;
9173
@@ -100,15 +82,14 @@ export class CommitFileNode extends ViewRefFileNode {
10082 private _description : string | undefined ;
10183 get description ( ) {
10284 if ( this . _description === undefined ) {
103- this . _description =
104- this . _displayAs & CommitFileNodeDisplayAs . CommitLabel
105- ? CommitFormatter . fromTemplate ( this . getCommitDescriptionTemplate ( ) , this . commit , {
106- truncateMessageAtNewLine : true ,
107- dateFormat : Container . config . defaultDateFormat
108- } )
109- : StatusFileFormatter . fromTemplate ( this . getCommitFileDescriptionTemplate ( ) , this . file , {
110- relativePath : this . relativePath
111- } ) ;
85+ this . _description = this . _options . displayAsCommit
86+ ? CommitFormatter . fromTemplate ( this . getCommitDescriptionTemplate ( ) , this . commit , {
87+ truncateMessageAtNewLine : true ,
88+ dateFormat : Container . config . defaultDateFormat
89+ } )
90+ : StatusFileFormatter . fromTemplate ( this . getCommitFileDescriptionTemplate ( ) , this . file , {
91+ relativePath : this . relativePath
92+ } ) ;
11293 }
11394 return this . _description ;
11495 }
@@ -124,15 +105,14 @@ export class CommitFileNode extends ViewRefFileNode {
124105 private _label : string | undefined ;
125106 get label ( ) {
126107 if ( this . _label === undefined ) {
127- this . _label =
128- this . _displayAs & CommitFileNodeDisplayAs . CommitLabel
129- ? CommitFormatter . fromTemplate ( this . getCommitTemplate ( ) , this . commit , {
130- truncateMessageAtNewLine : true ,
131- dateFormat : Container . config . defaultDateFormat
132- } )
133- : StatusFileFormatter . fromTemplate ( this . getCommitFileTemplate ( ) , this . file , {
134- relativePath : this . relativePath
135- } ) ;
108+ this . _label = this . _options . displayAsCommit
109+ ? CommitFormatter . fromTemplate ( this . getCommitTemplate ( ) , this . commit , {
110+ truncateMessageAtNewLine : true ,
111+ dateFormat : Container . config . defaultDateFormat
112+ } )
113+ : StatusFileFormatter . fromTemplate ( this . getCommitFileTemplate ( ) , this . file , {
114+ relativePath : this . relativePath
115+ } ) ;
136116 }
137117 return this . _label ;
138118 }
@@ -148,15 +128,17 @@ export class CommitFileNode extends ViewRefFileNode {
148128 }
149129
150130 protected get resourceType ( ) : string {
151- if ( ! this . commit . isUncommitted ) return ResourceType . CommitFile ;
131+ if ( ! this . commit . isUncommitted ) {
132+ return `${ ResourceType . File } +committed${ this . _options . inFileHistory ? '+history' : '' } ` ;
133+ }
152134
153135 return this . commit . isUncommittedStaged ? `${ ResourceType . File } +staged` : `${ ResourceType . File } +unstaged` ;
154136 }
155137
156138 private _tooltip : string | undefined ;
157139 get tooltip ( ) {
158140 if ( this . _tooltip === undefined ) {
159- if ( this . _displayAs & CommitFileNodeDisplayAs . CommitLabel ) {
141+ if ( this . _options . displayAsCommit ) {
160142 // eslint-disable-next-line no-template-curly-in-string
161143 const status = StatusFileFormatter . fromTemplate ( '${status}${ (originalPath)}' , this . file ) ;
162144 this . _tooltip = CommitFormatter . fromTemplate (
@@ -208,7 +190,7 @@ export class CommitFileNode extends ViewRefFileNode {
208190 line = this . commit . line . to . line - 1 ;
209191 }
210192 else {
211- line = this . _selection !== undefined ? this . _selection . active . line : 0 ;
193+ line = this . _options . selection !== undefined ? this . _options . selection . active . line : 0 ;
212194 }
213195
214196 const commandArgs : DiffWithPreviousCommandArgs = {
0 commit comments