@@ -402,6 +402,17 @@ class ViewModel {
402
402
get mode ( ) : ViewModelMode { return this . _mode ; }
403
403
set mode ( mode : ViewModelMode ) {
404
404
this . _mode = mode ;
405
+
406
+ for ( const item of this . items ) {
407
+ item . tree . clear ( ) ;
408
+
409
+ if ( mode === ViewModelMode . Tree ) {
410
+ for ( const resource of item . resources ) {
411
+ item . tree . add ( resource . sourceUri , resource ) ;
412
+ }
413
+ }
414
+ }
415
+
405
416
this . refresh ( ) ;
406
417
this . _onDidChangeMode . fire ( mode ) ;
407
418
}
@@ -428,10 +439,12 @@ class ViewModel {
428
439
group . onDidSplice ( splice => this . onDidSpliceGroup ( item , splice ) )
429
440
) ;
430
441
431
- const item = { group, resources, tree, disposable } ;
442
+ const item : IGroupItem = { group, resources, tree, disposable } ;
432
443
433
- for ( const resource of resources ) {
434
- item . tree . add ( resource . sourceUri , resource ) ;
444
+ if ( this . _mode === ViewModelMode . Tree ) {
445
+ for ( const resource of resources ) {
446
+ item . tree . add ( resource . sourceUri , resource ) ;
447
+ }
435
448
}
436
449
437
450
itemsToInsert . push ( item ) ;
@@ -447,14 +460,18 @@ class ViewModel {
447
460
}
448
461
449
462
private onDidSpliceGroup ( item : IGroupItem , { start, deleteCount, toInsert } : ISplice < ISCMResource > ) : void {
450
- for ( const resource of toInsert ) {
451
- item . tree . add ( resource . sourceUri , resource ) ;
463
+ if ( this . _mode === ViewModelMode . Tree ) {
464
+ for ( const resource of toInsert ) {
465
+ item . tree . add ( resource . sourceUri , resource ) ;
466
+ }
452
467
}
453
468
454
469
const deleted = item . resources . splice ( start , deleteCount , ...toInsert ) ;
455
470
456
- for ( const resource of deleted ) {
457
- item . tree . delete ( resource . sourceUri ) ;
471
+ if ( this . _mode === ViewModelMode . Tree ) {
472
+ for ( const resource of deleted ) {
473
+ item . tree . delete ( resource . sourceUri ) ;
474
+ }
458
475
}
459
476
460
477
this . refresh ( item ) ;
0 commit comments