Skip to content

Commit 81ee460

Browse files
authored
Merge pull request #350 from edgardmessias/order_resource
fix: Fixed order of resources groups
2 parents 8cb5a8d + 5ead722 commit 81ee460

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/repository.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,11 @@ export class Repository {
234234
this.conflicts.hideWhenEmpty = true;
235235

236236
this.disposables.push(this.changes);
237-
this.disposables.push(this.unversioned);
238237
this.disposables.push(this.conflicts);
239238

239+
// The this.unversioned can recreated by update state model
240+
this.disposables.push(toDisposable(() => this.unversioned.dispose()));
241+
240242
// Dispose the setInterval of Remote Changes
241243
this.disposables.push(
242244
toDisposable(() => {
@@ -584,9 +586,10 @@ export class Repository {
584586
}
585587

586588
this.changes.resourceStates = changes;
587-
this.unversioned.resourceStates = unversioned;
588589
this.conflicts.resourceStates = conflicts;
589590

591+
const prevChangelistsSize = this.changelists.size;
592+
590593
this.changelists.forEach((group, changelist) => {
591594
group.resourceStates = [];
592595
});
@@ -622,6 +625,20 @@ export class Repository {
622625
}
623626
});
624627

628+
// Recreate unversioned group to move after changelists
629+
if (prevChangelistsSize !== this.changelists.size) {
630+
this.unversioned.dispose();
631+
632+
this.unversioned = this.sourceControl.createResourceGroup(
633+
"unversioned",
634+
"Unversioned"
635+
) as ISvnResourceGroup;
636+
637+
this.unversioned.hideWhenEmpty = true;
638+
}
639+
640+
this.unversioned.resourceStates = unversioned;
641+
625642
if (configuration.get<boolean>("sourceControl.countUnversioned", false)) {
626643
counts.push(this.unversioned);
627644
}
@@ -631,11 +648,14 @@ export class Repository {
631648
0
632649
);
633650

634-
if (checkRemoteChanges) {
651+
// Recreate remoteChanges group to move after unversioned
652+
if (!this.remoteChanges || prevChangelistsSize !== this.changelists.size) {
635653
/**
636654
* Destroy and create for keep at last position
637655
*/
656+
let tempResourceStates: Resource[] = [];
638657
if (this.remoteChanges) {
658+
tempResourceStates = this.remoteChanges.resourceStates;
639659
this.remoteChanges.dispose();
640660
}
641661

@@ -645,6 +665,11 @@ export class Repository {
645665
) as ISvnResourceGroup;
646666

647667
this.remoteChanges.hideWhenEmpty = true;
668+
this.remoteChanges.resourceStates = tempResourceStates;
669+
}
670+
671+
// Update remote changes group
672+
if (checkRemoteChanges) {
648673
this.remoteChanges.resourceStates = remoteChanges;
649674

650675
if (remoteChanges.length !== this.remoteChangedFiles) {

0 commit comments

Comments
 (0)