[CMI] Improve CodeMetaInfoRenderer
1. Properly handle meta which start == end 2. Sort metainfos of one range by tag
This commit is contained in:
+5
-1
@@ -56,13 +56,17 @@ object CodeMetaInfoRenderer {
|
||||
current = next
|
||||
}
|
||||
}
|
||||
// Here we need to handle meta infos which has start == end and close them immediately
|
||||
checkOpenedAndCloseStringIfNeeded(opened, i, builder)
|
||||
builder.append(c)
|
||||
}
|
||||
checkOpenedAndCloseStringIfNeeded(opened, originalText.length, builder)
|
||||
}
|
||||
|
||||
private val metaInfoComparator = (compareBy<CodeMetaInfo> { it.start } then compareByDescending { it.end }) then compareBy { it.tag }
|
||||
|
||||
private fun getSortedCodeMetaInfos(metaInfos: Collection<CodeMetaInfo>): List<CodeMetaInfo> {
|
||||
return metaInfos.sortedWith(compareBy<CodeMetaInfo> { it.start }.then(compareByDescending { it.end }))
|
||||
return metaInfos.sortedWith(metaInfoComparator)
|
||||
}
|
||||
|
||||
private fun closeString(result: StringBuilder) = result.append("<!>")
|
||||
|
||||
Reference in New Issue
Block a user