Fixed previous commits of uncommited changes not showing in the same column

This commit is contained in:
Abdelilah El Aissaoui 2021-10-28 17:03:06 +02:00
parent 7c2029d602
commit 4a6542abcd
2 changed files with 23 additions and 11 deletions

View File

@ -63,7 +63,7 @@ class GraphCommitList : RevCommitList<GraphNode>() {
override fun enter(index: Int, currCommit: GraphNode) {
if(currCommit.id == parentId) {
graphCommit.graphParent = currCommit
currCommit.addChild(graphCommit)
currCommit.addChild(graphCommit, addFirst = true)
}
setupChildren(currCommit)

View File

@ -31,22 +31,34 @@ open class GraphNode(id: AnyObjectId?) : RevCommit(id), IGraphNode {
mergingLanes = addLane(graphLane, mergingLanes)
}
fun addChild(c: GraphNode) {
fun addChild(c: GraphNode, addFirst: Boolean = false) {
when (val childrenCount = children.count()) {
0 -> children = arrayOf(c)
1 -> if (!c.id.equals(children[0].id)) children = arrayOf(children[0], c)
1 -> {
if (!c.id.equals(children[0].id)) {
children = if (addFirst) {
arrayOf(c, children[0])
} else
arrayOf(children[0], c)
}
}
else -> {
for (pc in children)
if (c.id.equals(pc.id))
return
val n: Array<GraphNode> = children.copyOf(childrenCount + 1).run {
val resultArray = if (addFirst) {
val childList = mutableListOf(c)
childList.addAll(children)
childList.toTypedArray()
} else {
children.copyOf(childrenCount + 1).run {
this[childrenCount] = c
requireNoNulls()
}
}
n[childrenCount] = c
children = n
children = resultArray
}
}
}