mirror of
https://github.com/irmen/prog8.git
synced 2024-09-07 03:54:27 +00:00
fix %option merge not choosing correct block to merge into
This commit is contained in:
parent
5407429ec0
commit
9ca71bc937
@ -106,13 +106,15 @@ class ModuleImporter(private val program: Program,
|
|||||||
removeDirectivesFromImportedModule(importedModule)
|
removeDirectivesFromImportedModule(importedModule)
|
||||||
|
|
||||||
// modules can contain blocks with "merge" option.
|
// modules can contain blocks with "merge" option.
|
||||||
// their content has to be merged into already existing block with the same name.
|
// their content has to be merged into already existing other block with the same name.
|
||||||
val blocks = importedModule.statements.filterIsInstance<Block>()
|
val blocks = importedModule.statements.filterIsInstance<Block>()
|
||||||
for(block in blocks) {
|
for(block in blocks) {
|
||||||
if("merge" in block.options()) {
|
if("merge" in block.options()) {
|
||||||
val existingBlock = program.allBlocks.first { it.name==block.name}
|
val existingBlock = program.allBlocks.firstOrNull { it.name==block.name && it !== block}
|
||||||
existingBlock.statements.addAll(block.statements.filter { it !is Directive})
|
if(existingBlock!=null) {
|
||||||
importedModule.statements.remove(block)
|
existingBlock.statements.addAll(block.statements.filter { it !is Directive })
|
||||||
|
importedModule.statements.remove(block)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user