From a52cb43c3ebafbe382aa6b73ce84020c87ceb808 Mon Sep 17 00:00:00 2001 From: Edgard Lorraine Messias Date: Fri, 21 Sep 2018 10:11:53 -0300 Subject: [PATCH] fix: Fixed order of resources groups --- src/repository.ts | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/repository.ts b/src/repository.ts index 04e7ae91..980f0a95 100644 --- a/src/repository.ts +++ b/src/repository.ts @@ -233,9 +233,11 @@ export class Repository { this.conflicts.hideWhenEmpty = true; this.disposables.push(this.changes); - this.disposables.push(this.unversioned); this.disposables.push(this.conflicts); + // The this.unversioned can recreated by update state model + this.disposables.push(toDisposable(() => this.unversioned.dispose())); + // Dispose the setInterval of Remote Changes this.disposables.push( toDisposable(() => { @@ -508,9 +510,10 @@ export class Repository { } this.changes.resourceStates = changes; - this.unversioned.resourceStates = unversioned; this.conflicts.resourceStates = conflicts; + const prevChangelistsSize = this.changelists.size; + this.changelists.forEach((group, changelist) => { group.resourceStates = []; }); @@ -546,6 +549,20 @@ export class Repository { } }); + // Recreate unversioned group to move after changelists + if (prevChangelistsSize !== this.changelists.size) { + this.unversioned.dispose(); + + this.unversioned = this.sourceControl.createResourceGroup( + "unversioned", + "Unversioned" + ) as ISvnResourceGroup; + + this.unversioned.hideWhenEmpty = true; + } + + this.unversioned.resourceStates = unversioned; + if (configuration.get("sourceControl.countUnversioned", false)) { counts.push(this.unversioned); } @@ -555,11 +572,14 @@ export class Repository { 0 ); - if (checkRemoteChanges) { + // Recreate remoteChanges group to move after unversioned + if (!this.remoteChanges || prevChangelistsSize !== this.changelists.size) { /** * Destroy and create for keep at last position */ + let tempResourceStates: Resource[] = []; if (this.remoteChanges) { + tempResourceStates = this.remoteChanges.resourceStates; this.remoteChanges.dispose(); } @@ -569,6 +589,11 @@ export class Repository { ) as ISvnResourceGroup; this.remoteChanges.hideWhenEmpty = true; + this.remoteChanges.resourceStates = tempResourceStates; + } + + // Update remote changes group + if (checkRemoteChanges) { this.remoteChanges.resourceStates = remoteChanges; if (remoteChanges.length !== this.remoteChangedFiles) {