@@ -7,7 +7,6 @@ import { IAsyncDataSource, ITreeRenderer, ITreeNode } from 'vs/base/browser/ui/t
77import { ITextModelService } from 'vs/editor/common/services/resolverService' ;
88import { FuzzyScore , createMatches } from 'vs/base/common/filters' ;
99import { IResourceLabel , ResourceLabels } from 'vs/workbench/browser/labels' ;
10- import { URI } from 'vs/base/common/uri' ;
1110import { HighlightedLabel , IHighlight } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel' ;
1211import { IIdentityProvider , IListVirtualDelegate , IKeyboardNavigationLabelProvider } from 'vs/base/browser/ui/list/list' ;
1312import { Range } from 'vs/editor/common/core/range' ;
@@ -27,16 +26,20 @@ import { ThemeIcon } from 'vs/platform/theme/common/themeService';
2726
2827// --- VIEW MODEL
2928
30- export class FileElement {
29+ export class CategoryElement {
3130
32- readonly uri : URI ;
31+ constructor (
32+ readonly parent : BulkFileOperations ,
33+ readonly category : BulkCategory
34+ ) { }
35+ }
36+
37+ export class FileElement {
3338
3439 constructor (
35- readonly parent : BulkCategory | undefined ,
40+ readonly parent : CategoryElement | BulkFileOperations ,
3641 readonly edit : BulkFileOperation
37- ) {
38- this . uri = edit . uri ;
39- }
42+ ) { }
4043}
4144
4245export class TextEditElement {
@@ -48,7 +51,7 @@ export class TextEditElement {
4851 ) { }
4952}
5053
51- export type BulkEditElement = BulkCategory | FileElement | TextEditElement ;
54+ export type BulkEditElement = CategoryElement | FileElement | TextEditElement ;
5255
5356// --- DATA SOURCE
5457
@@ -73,13 +76,13 @@ export class BulkEditDataSource implements IAsyncDataSource<BulkFileOperations,
7376 // root -> file/text edits
7477 if ( element instanceof BulkFileOperations ) {
7578 return this . groupByFile
76- ? element . fileOperations . map ( op => new FileElement ( undefined , op ) )
77- : element . categories ;
79+ ? element . fileOperations . map ( op => new FileElement ( element , op ) )
80+ : element . categories . map ( cat => new CategoryElement ( element , cat ) ) ;
7881 }
7982
8083 // category
81- if ( element instanceof BulkCategory ) {
82- return element . fileOperations . map ( op => new FileElement ( element , op ) ) ;
84+ if ( element instanceof CategoryElement ) {
85+ return element . category . fileOperations . map ( op => new FileElement ( element , op ) ) ;
8386 }
8487
8588 // file: text edit
@@ -209,11 +212,11 @@ export class BulkEditIdentityProvider implements IIdentityProvider<BulkEditEleme
209212
210213 getId ( element : BulkEditElement ) : { toString ( ) : string ; } {
211214 if ( element instanceof FileElement ) {
212- return element . uri + JSON . stringify ( element . parent ?. metadata ) ;
215+ return element . edit . uri + ( element . parent instanceof CategoryElement ? JSON . stringify ( element . parent . category . metadata ) : '' ) ;
213216 } else if ( element instanceof TextEditElement ) {
214- return element . parent . uri . toString ( ) + JSON . stringify ( element . edit . textEdit ) ;
217+ return element . parent . edit . uri . toString ( ) + JSON . stringify ( element . edit . textEdit ) ;
215218 } else {
216- return JSON . stringify ( element . metadata ) ;
219+ return JSON . stringify ( element . category . metadata ) ;
217220 }
218221 }
219222}
@@ -248,7 +251,7 @@ class CategoryElementTemplate {
248251 }
249252}
250253
251- export class CategoryElementRenderer implements ITreeRenderer < BulkCategory , FuzzyScore , CategoryElementTemplate > {
254+ export class CategoryElementRenderer implements ITreeRenderer < CategoryElement , FuzzyScore , CategoryElementTemplate > {
252255
253256 static readonly id : string = 'CategoryElementRenderer' ;
254257
@@ -258,12 +261,12 @@ export class CategoryElementRenderer implements ITreeRenderer<BulkCategory, Fuzz
258261 return new CategoryElementTemplate ( container ) ;
259262 }
260263
261- renderElement ( node : ITreeNode < BulkCategory , FuzzyScore > , _index : number , template : CategoryElementTemplate ) : void {
264+ renderElement ( node : ITreeNode < CategoryElement , FuzzyScore > , _index : number , template : CategoryElementTemplate ) : void {
262265
263266 template . icon . style . setProperty ( '--background-dark' , null ) ;
264267 template . icon . style . setProperty ( '--background-light' , null ) ;
265268
266- const { metadata } = node . element ;
269+ const { metadata } = node . element . category ;
267270 if ( ThemeIcon . isThemeIcon ( metadata . iconPath ) ) {
268271 // css
269272 const className = ThemeIcon . asClassName ( metadata . iconPath ) ;
@@ -340,12 +343,12 @@ class FileElementTemplate {
340343
341344 this . _details . innerText = localize (
342345 'detail.rename' , "(renaming from {0})" ,
343- this . _labelService . getUriLabel ( element . uri , { relative : true } )
346+ this . _labelService . getUriLabel ( element . edit . uri , { relative : true } )
344347 ) ;
345348
346349 } else {
347350 // create, delete, edit: NAME
348- this . _label . setFile ( element . uri , {
351+ this . _label . setFile ( element . edit . uri , {
349352 matches : createMatches ( score ) ,
350353 fileKind : FileKind . FILE ,
351354 fileDecorations : { colors : true , badges : false } ,
@@ -489,9 +492,9 @@ export class BulkEditNaviLabelProvider implements IKeyboardNavigationLabelProvid
489492
490493 getKeyboardNavigationLabel ( element : BulkEditElement ) {
491494 if ( element instanceof FileElement ) {
492- return basename ( element . uri ) ;
493- } else if ( element instanceof BulkCategory ) {
494- return element . metadata . label ;
495+ return basename ( element . edit . uri ) ;
496+ } else if ( element instanceof CategoryElement ) {
497+ return element . category . metadata . label ;
495498 }
496499 return undefined ;
497500 }
0 commit comments