From ce7635909fd7aa923b80ef3d148b69e480a360f5 Mon Sep 17 00:00:00 2001 From: Anton Efimchuk Date: Thu, 19 Sep 2024 20:48:50 +0200 Subject: [PATCH] PY-75987 [Jupyter] Fix folding bar position calculation on notebook open GitOrigin-RevId: f8db05c845ceef6d0d5179a59256743107e1c49e --- .../notebooks/visualization/NotebookCellInlayManager.kt | 4 ++-- .../visualization/inlay/JupyterBoundsChangeHandler.kt | 2 +- .../intellij/notebooks/visualization/ui/DecoratedEditor.kt | 4 ++-- .../notebooks/visualization/ui/EditorCellFoldingBar.kt | 4 ++-- .../intellij/notebooks/visualization/ui/EditorCellOutputs.kt | 2 +- .../visualization/ui/EditorEmbeddedComponentLayoutManager.kt | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/notebooks/visualization/src/com/intellij/notebooks/visualization/NotebookCellInlayManager.kt b/notebooks/visualization/src/com/intellij/notebooks/visualization/NotebookCellInlayManager.kt index bf9e22ed3b50..cc47e902b7e3 100644 --- a/notebooks/visualization/src/com/intellij/notebooks/visualization/NotebookCellInlayManager.kt +++ b/notebooks/visualization/src/com/intellij/notebooks/visualization/NotebookCellInlayManager.kt @@ -70,7 +70,7 @@ class NotebookCellInlayManager private constructor( val newCtx = UpdateContext(force) updateCtx = newCtx try { - JupyterBoundsChangeHandler.get(editor)?.postponeUpdates() + JupyterBoundsChangeHandler.get(editor).postponeUpdates() val r = keepScrollingPositionWhile(editor) { val r = block(newCtx) updateCtx = null @@ -78,7 +78,7 @@ class NotebookCellInlayManager private constructor( r } inlaysChanged() - JupyterBoundsChangeHandler.get(editor)?.performPostponed() + JupyterBoundsChangeHandler.get(editor).performPostponed() r } finally { diff --git a/notebooks/visualization/src/com/intellij/notebooks/visualization/inlay/JupyterBoundsChangeHandler.kt b/notebooks/visualization/src/com/intellij/notebooks/visualization/inlay/JupyterBoundsChangeHandler.kt index 3c6487a5dfc8..29b2161dfe4d 100644 --- a/notebooks/visualization/src/com/intellij/notebooks/visualization/inlay/JupyterBoundsChangeHandler.kt +++ b/notebooks/visualization/src/com/intellij/notebooks/visualization/inlay/JupyterBoundsChangeHandler.kt @@ -120,6 +120,6 @@ class JupyterBoundsChangeHandler(val editor: EditorImpl) : Disposable { editor.putUserData(INSTANCE_KEY, updater) } - fun get(editor: Editor): JupyterBoundsChangeHandler? = INSTANCE_KEY.get(editor) + fun get(editor: Editor): JupyterBoundsChangeHandler = INSTANCE_KEY.get(editor) } } \ No newline at end of file diff --git a/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/DecoratedEditor.kt b/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/DecoratedEditor.kt index f38322e18762..8f824a3c4903 100644 --- a/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/DecoratedEditor.kt +++ b/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/DecoratedEditor.kt @@ -125,9 +125,9 @@ class DecoratedEditor private constructor( override fun validateTree() { keepScrollingPositionWhile(editor) { - JupyterBoundsChangeHandler.get(editor)?.postponeUpdates() + JupyterBoundsChangeHandler.get(editor).postponeUpdates() super.validateTree() - JupyterBoundsChangeHandler.get(editor)?.performPostponed() + JupyterBoundsChangeHandler.get(editor).performPostponed() } } } diff --git a/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/EditorCellFoldingBar.kt b/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/EditorCellFoldingBar.kt index f55b845edaac..8d381d37b793 100644 --- a/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/EditorCellFoldingBar.kt +++ b/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/EditorCellFoldingBar.kt @@ -42,7 +42,7 @@ class EditorCellFoldingBar( val panel = createFoldingBar() editor.gutterComponentEx.add(panel) this.panel = panel - JupyterBoundsChangeHandler.get(editor)?.subscribe(boundsChangeListener) + JupyterBoundsChangeHandler.get(editor).subscribe(boundsChangeListener) updateBounds() } else { @@ -64,7 +64,7 @@ class EditorCellFoldingBar( remove(it) repaint() } - JupyterBoundsChangeHandler.get(editor)?.unsubscribe(boundsChangeListener) + JupyterBoundsChangeHandler.get(editor).unsubscribe(boundsChangeListener) panel = null } } diff --git a/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/EditorCellOutputs.kt b/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/EditorCellOutputs.kt index ddaa9a763e69..24ca1f212e71 100644 --- a/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/EditorCellOutputs.kt +++ b/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/EditorCellOutputs.kt @@ -76,7 +76,7 @@ class EditorCellOutputs( field = value if (shouldUpdate) { - JupyterBoundsChangeHandler.get(editor)?.boundsChanged() + JupyterBoundsChangeHandler.get(editor).boundsChanged() } } diff --git a/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/EditorEmbeddedComponentLayoutManager.kt b/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/EditorEmbeddedComponentLayoutManager.kt index fa32d35635b7..1bc18576a299 100644 --- a/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/EditorEmbeddedComponentLayoutManager.kt +++ b/notebooks/visualization/src/com/intellij/notebooks/visualization/ui/EditorEmbeddedComponentLayoutManager.kt @@ -133,7 +133,7 @@ internal class EditorEmbeddedComponentLayoutManager(private val editor: EditorEx // [com.intellij.openapi.editor.impl.FoldingModelImpl.onCustomFoldRegionPropertiesChange] fires listeners // before make model consistent. // Here we have to call it once again to get correct bounds. - JupyterBoundsChangeHandler.get(customFoldRegion.editor)!!.boundsChanged() + JupyterBoundsChangeHandler.get(customFoldRegion.editor).boundsChanged() } override val order: Int