6
6
import { ValueWithChangeEvent } from '../../../../base/common/event.js' ;
7
7
import { Disposable } from '../../../../base/common/lifecycle.js' ;
8
8
import { observableFromEvent , ValueWithChangeEventFromObservable , waitForState } from '../../../../base/common/observable.js' ;
9
+ import { basename } from '../../../../base/common/path.js' ;
9
10
import { URI , UriComponents } from '../../../../base/common/uri.js' ;
10
11
import { IMultiDiffEditorOptions } from '../../../../editor/browser/widget/multiDiffEditor/multiDiffEditorWidgetImpl.js' ;
11
12
import { localize2 } from '../../../../nls.js' ;
@@ -89,21 +90,23 @@ interface ScmHistoryItemUriFields {
89
90
readonly repositoryId : string ;
90
91
readonly historyItemId : string ;
91
92
readonly historyItemParentId ?: string ;
93
+ readonly historyItemDisplayId ?: string ;
92
94
}
93
95
94
96
export class ScmHistoryItemResolver implements IMultiDiffSourceResolver {
95
97
static readonly scheme = 'scm-history-item' ;
96
98
97
99
public static getMultiDiffSourceUri ( provider : ISCMProvider , historyItem : ISCMHistoryItem ) : URI {
98
- const historyItemParentId = historyItem . parentIds . length > 0 ? historyItem . parentIds [ 0 ] : undefined ;
99
-
100
100
return URI . from ( {
101
101
scheme : ScmHistoryItemResolver . scheme ,
102
102
path : provider . rootUri ?. fsPath ,
103
103
query : JSON . stringify ( {
104
104
repositoryId : provider . id ,
105
105
historyItemId : historyItem . id ,
106
- historyItemParentId
106
+ historyItemParentId : historyItem . parentIds . length > 0
107
+ ? historyItem . parentIds [ 0 ]
108
+ : undefined ,
109
+ historyItemDisplayId : historyItem . displayId
107
110
} satisfies ScmHistoryItemUriFields )
108
111
} , true ) ;
109
112
}
@@ -124,13 +127,14 @@ export class ScmHistoryItemResolver implements IMultiDiffSourceResolver {
124
127
return undefined ;
125
128
}
126
129
127
- const { repositoryId, historyItemId, historyItemParentId } = query ;
130
+ const { repositoryId, historyItemId, historyItemParentId, historyItemDisplayId } = query ;
128
131
if ( typeof repositoryId !== 'string' || typeof historyItemId !== 'string' ||
129
- ( typeof historyItemParentId !== 'string' && historyItemParentId !== undefined ) ) {
132
+ ( typeof historyItemParentId !== 'string' && historyItemParentId !== undefined ) ||
133
+ ( typeof historyItemDisplayId !== 'string' && historyItemDisplayId !== undefined ) ) {
130
134
return undefined ;
131
135
}
132
136
133
- return { repositoryId, historyItemId, historyItemParentId } ;
137
+ return { repositoryId, historyItemId, historyItemParentId, historyItemDisplayId } ;
134
138
}
135
139
136
140
constructor ( @ISCMService private readonly _scmService : ISCMService ) { }
@@ -140,14 +144,21 @@ export class ScmHistoryItemResolver implements IMultiDiffSourceResolver {
140
144
}
141
145
142
146
async resolveDiffSource ( uri : URI ) : Promise < IResolvedMultiDiffSource > {
143
- const { repositoryId, historyItemId, historyItemParentId } = ScmHistoryItemResolver . parseUri ( uri ) ! ;
147
+ const { repositoryId, historyItemId, historyItemParentId, historyItemDisplayId } = ScmHistoryItemResolver . parseUri ( uri ) ! ;
144
148
145
149
const repository = this . _scmService . getRepository ( repositoryId ) ;
146
150
const historyProvider = repository ?. provider . historyProvider . get ( ) ;
147
151
const historyItemChanges = await historyProvider ?. provideHistoryItemChanges ( historyItemId , historyItemParentId ) ?? [ ] ;
148
152
149
153
const resources = ValueWithChangeEvent . const < readonly MultiDiffEditorItem [ ] > (
150
- historyItemChanges . map ( change => new MultiDiffEditorItem ( change . originalUri , change . modifiedUri , change . uri ) ) ) ;
154
+ historyItemChanges . map ( change => {
155
+ const goToFileEditorTitle = change . modifiedUri
156
+ ? `${ basename ( change . modifiedUri . fsPath ) } (${ historyItemDisplayId ?? historyItemId } )`
157
+ : undefined ;
158
+
159
+ return new MultiDiffEditorItem ( change . originalUri , change . modifiedUri , change . modifiedUri , goToFileEditorTitle ) ;
160
+ } )
161
+ ) ;
151
162
152
163
return { resources } ;
153
164
}
0 commit comments