diff --git a/src/repository.ts b/src/repository.ts index e68c1511..92b31f82 100644 --- a/src/repository.ts +++ b/src/repository.ts @@ -234,9 +234,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(() => { @@ -584,9 +586,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 = []; }); @@ -622,6 +625,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); } @@ -631,11 +648,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(); } @@ -645,6 +665,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) {