Skip to content

Commit 98e4628

Browse files
committed
comment line wrapping is supported
1 parent b8fd576 commit 98e4628

File tree

1 file changed

+32
-24
lines changed
  • EmmyLua-LS/src/main/kotlin/com/tang/vscode/documentation

1 file changed

+32
-24
lines changed

EmmyLua-LS/src/main/kotlin/com/tang/vscode/documentation/DocRenderer.kt

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -89,36 +89,44 @@ internal fun renderComment(sb: StringBuilder, comment: LuaComment?) {
8989
if (comment != null) {
9090
sb.append("\n\n")
9191
var child: PsiElement? = comment.firstChild
92+
var seenString = false
9293
while (child != null) {
93-
when (child) {
94-
is LuaDocTagParam -> {
95-
renderDocParam(sb, child)
94+
val elementType = child.node.elementType
95+
if (elementType == LuaDocTypes.STRING) {
96+
seenString = true
97+
sb.append(child.text)
98+
}
99+
else if (elementType == LuaDocTypes.DASHES) {
100+
if (seenString) {
96101
sb.append("\n")
97102
}
98-
is LuaDocTagReturn -> {
99-
val typeList = child.typeList
100-
if (typeList != null) {
101-
sb.appendLine("@_return_ : (")
102-
val list = typeList.tyList
103-
list.forEachIndexed { index, luaDocTy ->
104-
renderTypeUnion(if (index != 0) ", " else null, null, sb, luaDocTy)
105-
sb.append(" ")
106-
}
107-
sb.append(")")
108-
renderCommentString(null, null, sb, child.commentString)
103+
}
104+
else if (child is LuaDocPsiElement){
105+
seenString = false
106+
when (child) {
107+
is LuaDocTagParam -> {
108+
renderDocParam(sb, child)
109109
sb.append("\n")
110110
}
111-
}
112-
is LuaDocTagClass -> renderClassDef(sb, child)
113-
is LuaDocTagField -> renderFieldDef(sb, child)
114-
is LuaDocTagOverload -> renderOverload(sb, child)
115-
is LuaDocTagType -> renderTypeDef(sb, child)
116-
is LuaDocTagSee -> renderSee(sb, child)
117-
else -> {
118-
val elementType = child.node.elementType
119-
if (elementType === LuaDocTypes.STRING) {
120-
sb.append(child.text)
111+
is LuaDocTagReturn -> {
112+
val typeList = child.typeList
113+
if (typeList != null) {
114+
sb.appendLine("@_return_ : (")
115+
val list = typeList.tyList
116+
list.forEachIndexed { index, luaDocTy ->
117+
renderTypeUnion(if (index != 0) ", " else null, null, sb, luaDocTy)
118+
sb.append(" ")
119+
}
120+
sb.append(")")
121+
renderCommentString(null, null, sb, child.commentString)
122+
sb.append("\n")
123+
}
121124
}
125+
is LuaDocTagClass -> renderClassDef(sb, child)
126+
is LuaDocTagField -> renderFieldDef(sb, child)
127+
is LuaDocTagOverload -> renderOverload(sb, child)
128+
is LuaDocTagType -> renderTypeDef(sb, child)
129+
is LuaDocTagSee -> renderSee(sb, child)
122130
}
123131
}
124132
child = child.nextSibling

0 commit comments

Comments
 (0)