From db91821d231426835250e7f48d720d91c8a67e1f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 13 Dec 2025 09:26:06 -0800 Subject: [PATCH] Support in @example tags --- internal/ls/hover.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/internal/ls/hover.go b/internal/ls/hover.go index 25a961e316..c7a573f745 100644 --- a/internal/ls/hover.go +++ b/internal/ls/hover.go @@ -109,8 +109,24 @@ func (l *LanguageService) getDocumentationFromDeclaration(c *checker.Checker, de } comments := tag.Comments() if tag.Kind == ast.KindJSDocTag && tag.TagName().Text() == "example" { - b.WriteString("\n") commentText := strings.TrimRight(getCommentText(comments), " \t\r\n") + if strings.HasPrefix(commentText, "") { + if captionEnd := strings.Index(commentText, ""); captionEnd > 0 { + b.WriteString(" — ") + b.WriteString(commentText[len(""):captionEnd]) + commentText = commentText[captionEnd+len(""):] + // Trim leading blank lines from commentText + for { + s1 := strings.TrimLeft(commentText, " \t") + s2 := strings.TrimLeft(s1, "\r\n") + if len(s1) == len(s2) { + break + } + commentText = s2 + } + } + } + b.WriteString("\n") if len(commentText) > 6 && strings.HasPrefix(commentText, "```") && strings.HasSuffix(commentText, "```") && strings.Contains(commentText, "\n") { b.WriteString(commentText) b.WriteString("\n")