Skip to content

Commit dac43aa

Browse files
committed
feat(structure): 改进 HTML 标签的文本呈现 #397
添加对 HtmlTagTreeElement 和 PsiTreeElementBase 的特殊处理,以更准确地获取可呈现文本。这解决了某些 HTML 元素在结构视图中显示
1 parent 9bda9e7 commit dac43aa

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

core/src/main/kotlin/cc/unitmesh/devti/bridge/utils/StructureCommandUtil.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package cc.unitmesh.devti.bridge.utils
22

33
import com.intellij.ide.structureView.StructureView
44
import com.intellij.ide.structureView.StructureViewTreeElement
5+
import com.intellij.ide.structureView.impl.common.PsiTreeElementBase
56
import com.intellij.lang.LanguageStructureViewBuilder
7+
import com.intellij.lang.html.structureView.HtmlTagTreeElement
68
import com.intellij.openapi.application.ModalityState
79
import com.intellij.openapi.application.invokeLater
810
import com.intellij.openapi.application.runInEdt
@@ -79,7 +81,17 @@ object StructureCommandUtil {
7981
*/
8082
private fun traverseStructure(element: StructureViewTreeElement, depth: Int, sb: StringBuilder): StringBuilder {
8183
val indent = formatBeforeCode(element, depth)
82-
var str = element.presentation.presentableText
84+
val str = when(element) {
85+
is HtmlTagTreeElement -> {
86+
element.presentableText
87+
}
88+
is PsiTreeElementBase<*> -> {
89+
element.presentableText
90+
}
91+
else -> {
92+
element.presentation.presentableText
93+
}
94+
}
8395

8496
if (!str.isNullOrBlank()) {
8597
sb.append(indent).append(str).append("\n")

0 commit comments

Comments
 (0)