Wizard: fix incorrectly added modules to the tree

This commit is contained in:
Ilya Kirillov
2020-01-18 14:03:02 +03:00
parent 5392ff128f
commit 18090c0e0a
@@ -23,13 +23,13 @@ class TargetsModel(
val userObject = parentToAdd.userObject val userObject = parentToAdd.userObject
when { when {
userObject is Module && userObject.kind == ModuleKind.singleplatform -> { userObject is Module && userObject.kind == ModuleKind.singleplatform -> {
val indexOfLastModule = parent.children() val indexOfLastModule = parentToAdd.children()
.toList() .toList()
.indexOfLast { .indexOfLast {
it.safeAs<DefaultMutableTreeNode>()?.userObject is Module it.safeAs<DefaultMutableTreeNode>()?.userObject is Module
} }
if (indexOfLastModule == -1) parent.insert(this, 0) if (indexOfLastModule == -1) parentToAdd.insert(this, 0)
else parent.insert(this, indexOfLastModule) else parentToAdd.insert(this, indexOfLastModule)
} }
else -> parentToAdd.add(this) else -> parentToAdd.add(this)
} }