@@ -6,8 +6,8 @@ import com.github.lppedd.cc.brighter
66import com.github.lppedd.cc.darker
77import com.github.lppedd.cc.lookupElement.CommitTokenLookupElement
88import com.github.lppedd.cc.psiElement.*
9+ import com.github.lppedd.cc.scaled
910import com.intellij.lang.documentation.AbstractDocumentationProvider
10- import com.intellij.lang.documentation.DocumentationMarkup
1111import com.intellij.psi.PsiElement
1212import com.intellij.psi.PsiManager
1313import com.intellij.psi.impl.FakePsiElement
@@ -21,7 +21,7 @@ import javax.swing.Icon
2121 * @author Edoardo Luppi
2222 */
2323internal class CommitTokenDocumentationProvider : AbstractDocumentationProvider () {
24- private val lineSeparatorRegex = Regex (" \r\n |\n\r | \n |\r " )
24+ private val lineSeparatorRegex = Regex (" \r\n |\n |\r " )
2525
2626 override fun generateDoc (element : PsiElement ? , originalElement : PsiElement ? ): String? =
2727 when (element) {
@@ -59,47 +59,56 @@ internal class CommitTokenDocumentationProvider : AbstractDocumentationProvider(
5959 val value = token.getValue().trim()
6060 val hasCustomDocumentation = description.isNotEmpty() && token.getPresentation().hasCustomDocumentation()
6161 val totalLength = value.length + description.length
62- val sb = StringBuilder (if (totalLength == 0 ) return " " else totalLength + 140 )
62+
63+ if (totalLength == 0 ) {
64+ return " "
65+ }
66+
6367 val grayedColorHex = ColorUtil .toHex(UIUtil .getContextHelpForeground())
64- sb.append(" <div style='border-bottom: none; padding: 4px 7px 2px'>" )
65- .append(" <span style='color: #$grayedColorHex '>$title </span>" )
66- .append(" </div>" )
68+ val sb = StringBuilder (totalLength + 200 )
69+
70+ val px2 = " ${2 .scaled} px"
71+ val px4 = " ${4 .scaled} px"
6772
68- // See DocumentationMarkup.CONTENT_START
73+ // See DocumentationMarkup for the actual HTML elements used by default
6974 sb.append(" <div class='content'" )
7075
7176 if (hasCustomDocumentation) {
72- sb.append(" style='padding: 0'>" )
77+ sb.append(" style='padding: 0; '>" )
7378 } else {
7479 sb.append(' >' )
80+ sb.append(" <div style='color: #$grayedColorHex ; margin-bottom: $px4 ;'>$title </div>" )
7581 }
7682
7783 if (description.isNotEmpty()) {
7884 sb.append(description)
7985 } else {
80- sb.append(" <span style='color: #$grayedColorHex '>" )
86+ sb.append(" <span style='color: #$grayedColorHex ; '>" )
8187 .append(CCBundle [" cc.completion.documentation.noDescription" ])
8288 .append(" </span>" )
8389 }
8490
85- sb.append(DocumentationMarkup . CONTENT_END )
91+ sb.append(" </div> " )
8692
8793 if (value.isNotEmpty()) {
8894 if (hasCustomDocumentation) {
8995 // Emulate a styled <hr>, which is still unsupported in JEditorPane
9096 val colorHex = ColorUtil .toHex(getSeparatorColor())
91- sb.append(" <div style='margin: 4px 0 2px ; font-size: 0; border-top: thin solid #$colorHex '></div>" )
97+ sb.append(" <div style='margin: $px4 0 $px2 ; font-size: 0; border-top: thin solid #$colorHex ; '></div>" )
9298 }
9399
94- sb.append(DocumentationMarkup .SECTIONS_START )
95- .append(DocumentationMarkup .SECTION_HEADER_START )
96- .append(" <span style='color: #$grayedColorHex '>" )
100+ sb.append(" <table class='sections' style='margin-top: $px4 ;'>" )
101+ .append(" <tr>" )
102+ .append(" <td class='section'>" )
103+ .append(" <span style='color: #$grayedColorHex ;'>" )
97104 .append(CCBundle [" cc.completion.documentation.section.value" ])
98105 .append(" </span>" )
99- .append(DocumentationMarkup .SECTION_SEPARATOR )
106+ .append(" </td>" )
107+ .append(" <td>" )
100108 .append(value.replace(lineSeparatorRegex, " <br/>" ))
101- .append(DocumentationMarkup .SECTION_END )
102- .append(DocumentationMarkup .SECTIONS_END )
109+ .append(" </td>" )
110+ .append(" </tr>" )
111+ .append(" </table>" )
103112 }
104113
105114 return " $sb "
0 commit comments