@@ -4,17 +4,22 @@ import type { DiffWithPreviousCommandArgs } from '../../commands/diffWithPreviou
44import { StatusFileFormatter } from '../../git/formatters/statusFormatter' ;
55import { GitUri } from '../../git/gitUri' ;
66import type { GitFile } from '../../git/models/file' ;
7+ import type { GitRevisionReference } from '../../git/models/reference' ;
8+ import { uncommitted } from '../../git/models/revision' ;
79import { getGitFileStatusIcon } from '../../git/utils/fileStatus.utils' ;
10+ import { createReference } from '../../git/utils/reference.utils' ;
811import { createCommand } from '../../system/-webview/command' ;
912import { editorLineToDiffRange } from '../../system/-webview/vscode/editors' ;
13+ import { memoize } from '../../system/decorators/memoize' ;
1014import { dirname , joinPaths } from '../../system/path' ;
1115import type { ViewsWithCommits } from '../viewBase' ;
12- import { getFileTooltipMarkdown , ViewFileNode } from './abstract/viewFileNode' ;
16+ import { getFileTooltipMarkdown } from './abstract/viewFileNode' ;
1317import type { ViewNode } from './abstract/viewNode' ;
1418import { ContextValues } from './abstract/viewNode' ;
19+ import { ViewRefFileNode } from './abstract/viewRefNode' ;
1520import type { FileNode } from './folderNode' ;
1621
17- export class UncommittedFileNode extends ViewFileNode < 'uncommitted-file' , ViewsWithCommits > implements FileNode {
22+ export class UncommittedFileNode extends ViewRefFileNode < 'uncommitted-file' , ViewsWithCommits > implements FileNode {
1823 constructor ( view : ViewsWithCommits , parent : ViewNode , repoPath : string , file : GitFile ) {
1924 super ( 'uncommitted-file' , GitUri . fromFile ( file , repoPath ) , view , parent , file ) ;
2025 }
@@ -23,10 +28,55 @@ export class UncommittedFileNode extends ViewFileNode<'uncommitted-file', ViewsW
2328 return this . path ;
2429 }
2530
31+ private _description : string | undefined ;
32+ get description ( ) : string {
33+ this . _description ??= StatusFileFormatter . fromTemplate (
34+ this . view . config . formats . files . description ,
35+ { ...this . file } ,
36+ { relativePath : this . relativePath } ,
37+ ) ;
38+ return this . _description ;
39+ }
40+
41+ private _folderName : string | undefined ;
42+ get folderName ( ) : string {
43+ this . _folderName ??= dirname ( this . uri . relativePath ) ;
44+ return this . _folderName ;
45+ }
46+
47+ private _label : string | undefined ;
48+ get label ( ) : string {
49+ this . _label ??= StatusFileFormatter . fromTemplate (
50+ `\${file}` ,
51+ { ...this . file } ,
52+ { relativePath : this . relativePath } ,
53+ ) ;
54+ return this . _label ;
55+ }
56+
2657 get path ( ) : string {
2758 return this . file . path ;
2859 }
2960
61+ get priority ( ) : number {
62+ return 0 ;
63+ }
64+
65+ @memoize ( )
66+ get ref ( ) : GitRevisionReference {
67+ return createReference ( uncommitted , this . uri . repoPath ! , { refType : 'revision' } ) ;
68+ }
69+
70+ private _relativePath : string | undefined ;
71+ get relativePath ( ) : string | undefined {
72+ return this . _relativePath ;
73+ }
74+ set relativePath ( value : string | undefined ) {
75+ this . _relativePath = value ;
76+ this . _label = undefined ;
77+ this . _description = undefined ;
78+ }
79+
3080 getChildren ( ) : ViewNode [ ] {
3181 return [ ] ;
3282 }
@@ -54,52 +104,6 @@ export class UncommittedFileNode extends ViewFileNode<'uncommitted-file', ViewsW
54104 return item ;
55105 }
56106
57- private _description : string | undefined ;
58- get description ( ) : string {
59- if ( this . _description == null ) {
60- this . _description = StatusFileFormatter . fromTemplate (
61- this . view . config . formats . files . description ,
62- { ...this . file } ,
63- { relativePath : this . relativePath } ,
64- ) ;
65- }
66- return this . _description ;
67- }
68-
69- private _folderName : string | undefined ;
70- get folderName ( ) : string {
71- if ( this . _folderName == null ) {
72- this . _folderName = dirname ( this . uri . relativePath ) ;
73- }
74- return this . _folderName ;
75- }
76-
77- private _label : string | undefined ;
78- get label ( ) : string {
79- if ( this . _label == null ) {
80- this . _label = StatusFileFormatter . fromTemplate (
81- `\${file}` ,
82- { ...this . file } ,
83- { relativePath : this . relativePath } ,
84- ) ;
85- }
86- return this . _label ;
87- }
88-
89- get priority ( ) : number {
90- return 0 ;
91- }
92-
93- private _relativePath : string | undefined ;
94- get relativePath ( ) : string | undefined {
95- return this . _relativePath ;
96- }
97- set relativePath ( value : string | undefined ) {
98- this . _relativePath = value ;
99- this . _label = undefined ;
100- this . _description = undefined ;
101- }
102-
103107 override getCommand ( ) : Command | undefined {
104108 return createCommand < [ undefined , DiffWithPreviousCommandArgs ] > (
105109 'gitlens.diffWithPrevious:views' ,
0 commit comments