[PyCharm] Jupyter (fix): Restored drawing of the right border of the cell frame. #PY-81124 Fixed

(cherry picked from commit a813c603779ab698d831df087435a4ba62b8461b)

GitOrigin-RevId: 5a38325f712f29481a9eed29affc7c6289c01b6a
This commit is contained in:
Nikita Pavlenko
2025-05-15 13:15:25 +02:00
committed by intellij-monorepo-bot
parent 6aacbd504f
commit 19851d9cda
3 changed files with 18 additions and 20 deletions

View File

@@ -39,4 +39,4 @@ fun <T> ObservableProperty<T>.afterDistinctChange(parentDisposable: Disposable,
prevValue = it
setter(it)
}
}
}

View File

@@ -76,7 +76,7 @@ class DecoratedEditor private constructor(
editorImpl.setMode(NotebookEditorMode.COMMAND)
}
updateSelectionAfterClick(hoveredCell.interval, event.isCtrlPressed(),
event.isShiftPressed(), event.button)
event.isShiftPressed(), event.button)
}
}
@@ -92,6 +92,8 @@ class DecoratedEditor private constructor(
private val editorViewport: JViewport,
component: Component,
) : JPanel(BorderLayout()) {
// The only need to use JLayer here is our frame borders around notebook cells.
private val layeredPane: JLayer<JPanel>
private val overlayLines = mutableListOf<Pair<Line2D, Color>>()
@@ -107,24 +109,22 @@ class DecoratedEditor private constructor(
add(viewportWrapper, BorderLayout.CENTER)
}
layeredPane = JLayer(editorPanel).apply {
setUI(object : LayerUI<JPanel>() {
override fun paint(graphics: Graphics, component: JComponent) {
super.paint(graphics, component)
layeredPane = JLayer(editorPanel, object : LayerUI<JPanel>() {
override fun paint(graphics: Graphics, component: JComponent) {
super.paint(graphics, component)
val g2d = graphics.create() as Graphics2D
try {
for ((line, color) in overlayLines) {
g2d.color = color
g2d.draw(line)
}
}
finally {
g2d.dispose()
val g2d = graphics.create() as Graphics2D
try {
for ((line, color) in overlayLines) {
g2d.color = color
g2d.draw(line)
}
}
})
}
finally {
g2d.dispose()
}
}
})
add(layeredPane, BorderLayout.CENTER)
}
@@ -148,7 +148,6 @@ class DecoratedEditor private constructor(
}
}
override fun inlayClicked(clickedCell: NotebookCellLines.Interval, ctrlPressed: Boolean, shiftPressed: Boolean, mouseButton: Int) {
editorImpl.setMode(NotebookEditorMode.COMMAND)
updateSelectionAfterClick(clickedCell, ctrlPressed, shiftPressed, mouseButton)

View File

@@ -36,6 +36,7 @@ class EditorCellFrameManager(private val editorCell: EditorCell) : Disposable {
editorCell.isSelected.afterDistinctChange(this) {
updateCellFrameShow()
}
editorCell.isHovered.afterDistinctChange(this) {
updateCellFrameShow()
}
@@ -44,7 +45,6 @@ class EditorCellFrameManager(private val editorCell: EditorCell) : Disposable {
updateCellFrameShow()
}
editor.notebookAppearance.cellFrameSelectedColor.afterChange(this) {
updateCellFrameShow()
}
@@ -143,7 +143,6 @@ class EditorCellFrameManager(private val editorCell: EditorCell) : Disposable {
}
}
companion object {
fun create(editorCell: EditorCell): EditorCellFrameManager? =
if (editorCell.interval.type == CellType.MARKDOWN && Registry.`is`("jupyter.markdown.cells.border") ||