Skip to content

Commit a52cb43

Browse files
committed
fix: Fixed order of resources groups
1 parent 5393373 commit a52cb43

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
@@ -233,9 +233,11 @@ export class Repository {
233233
this.conflicts.hideWhenEmpty = true;
234234

235235
this.disposables.push(this.changes);
236-
this.disposables.push(this.unversioned);
237236
this.disposables.push(this.conflicts);
238237

238+
// The this.unversioned can recreated by update state model
239+
this.disposables.push(toDisposable(() => this.unversioned.dispose()));
240+
239241
// Dispose the setInterval of Remote Changes
240242
this.disposables.push(
241243
toDisposable(() => {
@@ -508,9 +510,10 @@ export class Repository {
508510
}
509511

510512
this.changes.resourceStates = changes;
511-
this.unversioned.resourceStates = unversioned;
512513
this.conflicts.resourceStates = conflicts;
513514

515+
const prevChangelistsSize = this.changelists.size;
516+
514517
this.changelists.forEach((group, changelist) => {
515518
group.resourceStates = [];
516519
});
@@ -546,6 +549,20 @@ export class Repository {
546549
}
547550
});
548551

552+
// Recreate unversioned group to move after changelists
553+
if (prevChangelistsSize !== this.changelists.size) {
554+
this.unversioned.dispose();
555+
556+
this.unversioned = this.sourceControl.createResourceGroup(
557+
"unversioned",
558+
"Unversioned"
559+
) as ISvnResourceGroup;
560+
561+
this.unversioned.hideWhenEmpty = true;
562+
}
563+
564+
this.unversioned.resourceStates = unversioned;
565+
549566
if (configuration.get<boolean>("sourceControl.countUnversioned", false)) {
550567
counts.push(this.unversioned);
551568
}
@@ -555,11 +572,14 @@ export class Repository {
555572
0
556573
);
557574

558-
if (checkRemoteChanges) {
575+
// Recreate remoteChanges group to move after unversioned
576+
if (!this.remoteChanges || prevChangelistsSize !== this.changelists.size) {
559577
/**
560578
* Destroy and create for keep at last position
561579
*/
580+
let tempResourceStates: Resource[] = [];
562581
if (this.remoteChanges) {
582+
tempResourceStates = this.remoteChanges.resourceStates;
563583
this.remoteChanges.dispose();
564584
}
565585

@@ -569,6 +589,11 @@ export class Repository {
569589
) as ISvnResourceGroup;
570590

571591
this.remoteChanges.hideWhenEmpty = true;
592+
this.remoteChanges.resourceStates = tempResourceStates;
593+
}
594+
595+
// Update remote changes group
596+
if (checkRemoteChanges) {
572597
this.remoteChanges.resourceStates = remoteChanges;
573598

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

0 commit comments

Comments
 (0)