Skip to content

bugfix: 修复右键重构此处时,选择代码过多,导致内存溢出问题 #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.intellij.util.ui.JBEmptyBorder
import com.intellij.util.ui.UIUtil
import javax.accessibility.AccessibleContext
import javax.swing.JEditorPane
import org.apache.commons.text.StringEscapeUtils

class DisplayComponent(question: String) : JEditorPane() {
init {
Expand All @@ -16,8 +17,7 @@ class DisplayComponent(question: String) : JEditorPane() {
this.text = question
this.isOpaque = false
this.putClientProperty(
AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
StringUtil.unescapeXmlEntities(StringUtil.stripHtml(question, " "))
AccessibleContext.ACCESSIBLE_NAME_PROPERTY, stripHtmlAndUnescapeXmlEntities(question)
)

if (this.caret != null) {
Expand All @@ -28,4 +28,11 @@ class DisplayComponent(question: String) : JEditorPane() {
fun updateMessage(content: String) {
this.text = content
}

private fun stripHtmlAndUnescapeXmlEntities(input: String): String {
// 使用 Jsoup 去除HTML标签
val text = Jsoup.parse(input).text()
// 使用 Apache Commons Text 解码XML实体
return StringEscapeUtils.unescapeXml(text)
}
}
Loading