PY-75987 [Jupyter] Fix folding bar position calculation on notebook open

GitOrigin-RevId: f8db05c845ceef6d0d5179a59256743107e1c49e
This commit is contained in:
Anton Efimchuk
2024-09-19 20:48:50 +02:00
committed by intellij-monorepo-bot
parent 6c9df4d083
commit ce7635909f
6 changed files with 9 additions and 9 deletions

View File

@@ -70,7 +70,7 @@ class NotebookCellInlayManager private constructor(
val newCtx = UpdateContext(force) val newCtx = UpdateContext(force)
updateCtx = newCtx updateCtx = newCtx
try { try {
JupyterBoundsChangeHandler.get(editor)?.postponeUpdates() JupyterBoundsChangeHandler.get(editor).postponeUpdates()
val r = keepScrollingPositionWhile(editor) { val r = keepScrollingPositionWhile(editor) {
val r = block(newCtx) val r = block(newCtx)
updateCtx = null updateCtx = null
@@ -78,7 +78,7 @@ class NotebookCellInlayManager private constructor(
r r
} }
inlaysChanged() inlaysChanged()
JupyterBoundsChangeHandler.get(editor)?.performPostponed() JupyterBoundsChangeHandler.get(editor).performPostponed()
r r
} }
finally { finally {

View File

@@ -120,6 +120,6 @@ class JupyterBoundsChangeHandler(val editor: EditorImpl) : Disposable {
editor.putUserData(INSTANCE_KEY, updater) editor.putUserData(INSTANCE_KEY, updater)
} }
fun get(editor: Editor): JupyterBoundsChangeHandler? = INSTANCE_KEY.get(editor) fun get(editor: Editor): JupyterBoundsChangeHandler = INSTANCE_KEY.get(editor)
} }
} }

View File

@@ -125,9 +125,9 @@ class DecoratedEditor private constructor(
override fun validateTree() { override fun validateTree() {
keepScrollingPositionWhile(editor) { keepScrollingPositionWhile(editor) {
JupyterBoundsChangeHandler.get(editor)?.postponeUpdates() JupyterBoundsChangeHandler.get(editor).postponeUpdates()
super.validateTree() super.validateTree()
JupyterBoundsChangeHandler.get(editor)?.performPostponed() JupyterBoundsChangeHandler.get(editor).performPostponed()
} }
} }
} }

View File

@@ -42,7 +42,7 @@ class EditorCellFoldingBar(
val panel = createFoldingBar() val panel = createFoldingBar()
editor.gutterComponentEx.add(panel) editor.gutterComponentEx.add(panel)
this.panel = panel this.panel = panel
JupyterBoundsChangeHandler.get(editor)?.subscribe(boundsChangeListener) JupyterBoundsChangeHandler.get(editor).subscribe(boundsChangeListener)
updateBounds() updateBounds()
} }
else { else {
@@ -64,7 +64,7 @@ class EditorCellFoldingBar(
remove(it) remove(it)
repaint() repaint()
} }
JupyterBoundsChangeHandler.get(editor)?.unsubscribe(boundsChangeListener) JupyterBoundsChangeHandler.get(editor).unsubscribe(boundsChangeListener)
panel = null panel = null
} }
} }

View File

@@ -76,7 +76,7 @@ class EditorCellOutputs(
field = value field = value
if (shouldUpdate) { if (shouldUpdate) {
JupyterBoundsChangeHandler.get(editor)?.boundsChanged() JupyterBoundsChangeHandler.get(editor).boundsChanged()
} }
} }

View File

@@ -133,7 +133,7 @@ internal class EditorEmbeddedComponentLayoutManager(private val editor: EditorEx
// [com.intellij.openapi.editor.impl.FoldingModelImpl.onCustomFoldRegionPropertiesChange] fires listeners // [com.intellij.openapi.editor.impl.FoldingModelImpl.onCustomFoldRegionPropertiesChange] fires listeners
// before make model consistent. // before make model consistent.
// Here we have to call it once again to get correct bounds. // 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 override val order: Int