Skip to content

Commit d4b94b9

Browse files
authored
Merge pull request #82341 from microsoft/joao/release/1.39/fix-82203-2
Fix #82203 for recovery
2 parents e331b5f + 717bcf0 commit d4b94b9

File tree

2 files changed

+48
-15
lines changed

2 files changed

+48
-15
lines changed

src/vs/base/common/resourceTree.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ class BranchNode<T, C> extends Node<C> implements IBranchNode<T, C> {
6969
delete(path: string): void {
7070
this._children.delete(path);
7171
}
72+
73+
clear(): void {
74+
this._children.clear();
75+
}
7276
}
7377

7478
class LeafNode<T, C> extends Node<C> implements ILeafNode<T, C> {
@@ -195,4 +199,8 @@ export class ResourceTree<T extends NonNullable<any>, C> {
195199
node.delete(name);
196200
return child.element;
197201
}
202+
203+
clear(): void {
204+
this.root.clear();
205+
}
198206
}

src/vs/workbench/contrib/scm/browser/repositoryPanel.ts

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,17 @@ class ViewModel {
402402
get mode(): ViewModelMode { return this._mode; }
403403
set mode(mode: ViewModelMode) {
404404
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+
405416
this.refresh();
406417
this._onDidChangeMode.fire(mode);
407418
}
@@ -428,10 +439,12 @@ class ViewModel {
428439
group.onDidSplice(splice => this.onDidSpliceGroup(item, splice))
429440
);
430441

431-
const item = { group, resources, tree, disposable };
442+
const item: IGroupItem = { group, resources, tree, disposable };
432443

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+
}
435448
}
436449

437450
itemsToInsert.push(item);
@@ -447,14 +460,18 @@ class ViewModel {
447460
}
448461

449462
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+
}
452467
}
453468

454469
const deleted = item.resources.splice(start, deleteCount, ...toInsert);
455470

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+
}
458475
}
459476

460477
this.refresh(item);
@@ -696,15 +713,21 @@ export class RepositoryPanel extends ViewletPanel {
696713
this._register(this.tree.onContextMenu(this.onListContextMenu, this));
697714
this._register(this.tree);
698715

699-
let mode = this.configurationService.getValue<'tree' | 'list'>('scm.defaultViewMode') === 'list' ? ViewModelMode.List : ViewModelMode.Tree;
716+
let mode: ViewModelMode;
700717

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;
702724

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;
705727

706-
if (typeof storageMode === 'string') {
707-
mode = storageMode;
728+
if (typeof storageMode === 'string') {
729+
mode = storageMode;
730+
}
708731
}
709732
}
710733

@@ -718,8 +741,10 @@ export class RepositoryPanel extends ViewletPanel {
718741
this._register(this.themeService.onDidFileIconThemeChange(this.updateIndentStyles, this));
719742
this._register(this.viewModel.onDidChangeMode(this.onDidChangeMode, this));
720743

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+
}
723748

724749
this._register(this.onDidChangeBodyVisibility(this._onDidChangeVisibility, this));
725750

0 commit comments

Comments
 (0)