@@ -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 ) ;
@@ -696,15 +713,21 @@ export class RepositoryPanel extends ViewletPanel {
696
713
this . _register ( this . tree . onContextMenu ( this . onListContextMenu , this ) ) ;
697
714
this . _register ( this . tree ) ;
698
715
699
- let mode = this . configurationService . getValue < 'tree' | 'list' > ( 'scm.defaultViewMode' ) === 'list' ? ViewModelMode . List : ViewModelMode . Tree ;
716
+ let mode : ViewModelMode ;
700
717
701
- const rootUri = this . repository . provider . rootUri ;
718
+ if ( this . repository . provider . contextValue !== 'git' ) {
719
+ mode = ViewModelMode . List ;
720
+ } else {
721
+ mode = this . configurationService . getValue < 'tree' | 'list' > ( 'scm.defaultViewMode' ) === 'list' ? ViewModelMode . List : ViewModelMode . Tree ;
722
+
723
+ const rootUri = this . repository . provider . rootUri ;
702
724
703
- if ( typeof rootUri !== 'undefined' ) {
704
- const storageMode = this . storageService . get ( `scm.repository.viewMode:${ rootUri . toString ( ) } ` , StorageScope . WORKSPACE ) as ViewModelMode ;
725
+ if ( typeof rootUri !== 'undefined' ) {
726
+ const storageMode = this . storageService . get ( `scm.repository.viewMode:${ rootUri . toString ( ) } ` , StorageScope . WORKSPACE ) as ViewModelMode ;
705
727
706
- if ( typeof storageMode === 'string' ) {
707
- mode = storageMode ;
728
+ if ( typeof storageMode === 'string' ) {
729
+ mode = storageMode ;
730
+ }
708
731
}
709
732
}
710
733
@@ -718,8 +741,10 @@ export class RepositoryPanel extends ViewletPanel {
718
741
this . _register ( this . themeService . onDidFileIconThemeChange ( this . updateIndentStyles , this ) ) ;
719
742
this . _register ( this . viewModel . onDidChangeMode ( this . onDidChangeMode , this ) ) ;
720
743
721
- this . toggleViewModelModeAction = new ToggleViewModeAction ( this . viewModel ) ;
722
- this . _register ( this . toggleViewModelModeAction ) ;
744
+ if ( this . repository . provider . contextValue === 'git' ) {
745
+ this . toggleViewModelModeAction = new ToggleViewModeAction ( this . viewModel ) ;
746
+ this . _register ( this . toggleViewModelModeAction ) ;
747
+ }
723
748
724
749
this . _register ( this . onDidChangeBodyVisibility ( this . _onDidChangeVisibility , this ) ) ;
725
750
0 commit comments