From b201353ae4cf1859fcaca7b897fbcbfbf7ed4e3c Mon Sep 17 00:00:00 2001 From: azerr Date: Mon, 29 Jul 2024 11:30:47 +0200 Subject: [PATCH] fix: Wrong code block renderer when documentation contains CLRF Fixes #368 Signed-off-by: azerr --- .../features/documentation/LSPDocumentationHelper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/redhat/devtools/lsp4ij/features/documentation/LSPDocumentationHelper.java b/src/main/java/com/redhat/devtools/lsp4ij/features/documentation/LSPDocumentationHelper.java index c6e412a38..79513fcbe 100644 --- a/src/main/java/com/redhat/devtools/lsp4ij/features/documentation/LSPDocumentationHelper.java +++ b/src/main/java/com/redhat/devtools/lsp4ij/features/documentation/LSPDocumentationHelper.java @@ -11,6 +11,7 @@ package com.redhat.devtools.lsp4ij.features.documentation; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtilRt; import com.intellij.psi.PsiFile; import com.redhat.devtools.lsp4ij.internal.StringUtils; import org.eclipse.lsp4j.*; @@ -96,7 +97,7 @@ private LSPDocumentationHelper() { }) .filter(Objects::nonNull) .toList(); - } else if (hoverContents.isRight()){ + } else if (hoverContents.isRight()) { MarkupContent content = hoverContents.getRight(); if (isValidContent(content)) { return List.of(content); @@ -134,7 +135,7 @@ public static String convertToHtml(@NotNull List contents, } MarkupContent content = contents.get(i); htmlBody.append(MarkupKind.MARKDOWN.equals(content.getKind()) ? - MarkdownConverter.getInstance(project).toHtml(content.getValue(), file) : + MarkdownConverter.getInstance(project).toHtml(StringUtilRt.convertLineSeparators(content.getValue()), file) : content.getValue()); } return htmlBody.toString();