IJPL-150388 Exception on viewing package details in the package.json

GitOrigin-RevId: ce643f739606e12c2a7bf353b53c6abbd9f99b06
This commit is contained in:
Piotr Tomiak
2024-06-07 13:57:05 +00:00
committed by intellij-monorepo-bot
parent 3af99ce0e8
commit b0edf85f22
3 changed files with 25 additions and 11 deletions
@@ -119,7 +119,8 @@ internal class DocumentationPanePreferredWidthProvider(
// or an actual preferred span no larger than MIN_CELL_WIDTH
val preferredSectionWidth =
cellPreferredSectionWidth[cell]
?: min(MIN_CELL_WIDTH, cell.getPreferredSpan(View.X_AXIS).toInt().takeIf { it > 0 }?.let { it + cell.cssMargin.width } ?: MIN_CELL_WIDTH)
?: min(MIN_CELL_WIDTH, cell.getPreferredSpan(View.X_AXIS).toInt().takeIf { it > 0 }?.let { it + cell.cssMargin.width }
?: MIN_CELL_WIDTH)
// A cell can contain a table, so let's find out the maximum preferred size from any child table
return max(preferredSectionWidth, getPreferredWidthForRows(cell.parent, cell2SubCells[cell]))
@@ -143,7 +144,7 @@ internal class DocumentationPanePreferredWidthProvider(
result.add(cur)
}
for (i in 0 until cur.viewCount) {
queue.add(cur.getView(i))
cur.getView(i)?.let { queue.add(it) }
}
}
return result
@@ -4,6 +4,7 @@ package com.intellij.ui.components
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.thisLogger
import com.intellij.openapi.editor.colors.EditorColorsScheme
import com.intellij.util.containers.addAllIfNotNull
import com.intellij.util.ui.*
@@ -169,7 +170,11 @@ open class JBHtmlPane(
override fun setText(t: @Nls String?) {
myText = t?.let { service.transpileHtmlPaneInput(it) } ?: ""
super.setText(myText)
try {
super.setText(myText)
} catch (e: Throwable) {
thisLogger().error("Failed to set contents of the HTML pane", e)
}
}
override fun setEditorKit(kit: EditorKit) {
@@ -147,18 +147,26 @@ internal class InlineViewEx(elem: Element) : InlineView(elem) {
private fun updatePaddingsAndMargins(force: Boolean) {
val parentView = parent
val index = (0..<parentView.viewCount).firstOrNull { parentView.getView(it) === this } ?: -1
// Heuristics to determine whether we are within the same inline (e.g. <span>) element with paddings.
// Nested inline element insets are not supported, because hierarchy of inline elements is not preserved.
val prevSibling = getSibling(parentView, index, -1)
val nextSibling = getSibling(parentView, index, 1)
val cssPadding = this.cssPadding
val cssMargin = this.cssMargin
val startView = prevSibling?.cssPadding != cssPadding || prevSibling.cssMargin != cssMargin
val endView = nextSibling?.cssPadding != cssPadding || nextSibling.cssMargin != cssMargin
val startView: Boolean
val endView: Boolean
if (parentView == null) {
startView = true
endView = true
} else {
val index = (0..<parentView.viewCount).firstOrNull { parentView.getView(it) === this } ?: -1
// Heuristics to determine whether we are within the same inline (e.g. <span>) element with paddings.
// Nested inline element insets are not supported, because hierarchy of inline elements is not preserved.
val prevSibling = getSibling(parentView, index, -1)
val nextSibling = getSibling(parentView, index, 1)
startView = prevSibling?.cssPadding != cssPadding || prevSibling.cssMargin != cssMargin
endView = nextSibling?.cssPadding != cssPadding || nextSibling.cssMargin != cssMargin
}
if (!force && startView == this.startView && endView == this.endView) {
return