PY-69893 Fix cell outputs update after clear

GitOrigin-RevId: 42905a11209130d9fde8c8f1af6459550e4ba417
This commit is contained in:
Anton Efimchuk
2024-05-07 13:26:43 +02:00
committed by intellij-monorepo-bot
parent 601aa49801
commit 059d525249
3 changed files with 13 additions and 2 deletions

View File

@@ -69,8 +69,8 @@ class EditorCellOutput internal constructor(private val editor: EditorEx, privat
fun onViewportChange() {
val component = component.mainComponent as? NotebookOutputInlayShowable ?: return
if (component !is Component) return
if (component !is JComponent) return
validateComponent(component)
val componentRect = SwingUtilities.convertRectangle(component, component.bounds, editor.scrollPane.viewport.view)
component.shown = editor.scrollPane.viewport.viewRect.intersects(componentRect)
}

View File

@@ -98,6 +98,7 @@ class EditorCellOutputs(
?: emptyList()
updateData(outputDataKeys)
recreateInlayIfNecessary()
onViewportChange()
}
private fun recreateInlayIfNecessary() {
@@ -116,6 +117,7 @@ class EditorCellOutputs(
}
else {
inlay?.let { Disposer.dispose(it) }
inlay = null
}
}

View File

@@ -7,6 +7,7 @@ import com.intellij.openapi.editor.ex.EditorEx
import com.intellij.openapi.editor.impl.EditorComponentImpl
import com.intellij.openapi.editor.impl.EditorEmbeddedComponentManager
import com.intellij.openapi.editor.impl.EditorEmbeddedComponentManager.Properties.RendererFactory
import java.awt.Container
import java.awt.event.ComponentAdapter
import java.awt.event.ComponentEvent
import java.awt.event.HierarchyEvent
@@ -112,3 +113,11 @@ fun JComponent.yOffsetFromEditor(editor: Editor): Int? =
SwingUtilities.convertPoint(this, 0, 0, editor.contentComponent).y
.takeIf { it >= 0 }
?.let { it + insets.top }
fun validateComponent(c: Container) {
var validationRoot = c
while (!validationRoot.isValidateRoot && validationRoot.parent != null) {
validationRoot = validationRoot.parent
}
validationRoot.validate()
}