Skip to content

Commit

Permalink
Fix roots order on tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyan11 committed Dec 15, 2023
1 parent 33f6371 commit 62a083d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Pyramid-Bloc/PyramidTreePresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,22 @@ PyramidTreePresenter >> tree [
{ #category : #'as yet unclassified' }
PyramidTreePresenter >> updateRoots [

| roots parent shouldOrder |
self shouldUpdateSelection: false.
[
self tree roots: self projectModel roots asArray ] ensure: [ self shouldUpdateSelection: true ]

roots := self projectModel roots asArray.
parent := nil.

"If roots all have the same parent then it should be ordered by the parent children order."
shouldOrder := (roots allSatisfy: [ :each |
parent ifNil: [ parent := each parent ].
each parent = parent ]) and: [
parent notNil and: [
parent childrenCount = roots size ] ].
shouldOrder ifTrue: [ roots := parent children asArray ].

[ self tree roots: roots ] ensure: [
self shouldUpdateSelection: true ]
]

{ #category : #'as yet unclassified' }
Expand Down

0 comments on commit 62a083d

Please sign in to comment.