mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[PyCharm] PY-77218 Jupyter bugfix - don't show add cells toolbar at the end of the console + minor refactoring
(cherry picked from commit bff263fb3c7131180d80e44cae52f9ff39fc27c3) GitOrigin-RevId: ebf47b6024e1178a6d9b2fb3421285a3761856b0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4b6c16f336
commit
158e70ea4d
@@ -2,6 +2,7 @@ package com.intellij.notebooks.visualization
|
||||
|
||||
import com.intellij.ide.ui.LafManagerListener
|
||||
import com.intellij.notebooks.ui.isFoldingEnabledKey
|
||||
import com.intellij.notebooks.ui.visualization.NotebookBelowLastCellPanel
|
||||
import com.intellij.notebooks.visualization.inlay.JupyterBoundsChangeHandler
|
||||
import com.intellij.notebooks.visualization.ui.*
|
||||
import com.intellij.notebooks.visualization.ui.EditorCellEventListener.*
|
||||
@@ -23,6 +24,7 @@ import com.intellij.openapi.editor.ex.EditorEx
|
||||
import com.intellij.openapi.editor.ex.FoldingListener
|
||||
import com.intellij.openapi.editor.ex.FoldingModelEx
|
||||
import com.intellij.openapi.editor.impl.EditorImpl
|
||||
import com.intellij.openapi.editor.Inlay
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
@@ -48,6 +50,8 @@ class NotebookCellInlayManager private constructor(
|
||||
|
||||
val views = mutableMapOf<EditorCell, EditorCellView>()
|
||||
|
||||
private var belowLastCellInlay: Inlay<*>? = null
|
||||
|
||||
/**
|
||||
* Listens for inlay changes (called after all inlays are updated). Feel free to convert it to the EP if you need another listener
|
||||
*/
|
||||
@@ -183,6 +187,7 @@ class NotebookCellInlayManager private constructor(
|
||||
|
||||
setupFoldingListener()
|
||||
setupSelectionUI()
|
||||
addBelowLastCellInlay()
|
||||
|
||||
cellEventListeners.addListener(object : EditorCellEventListener {
|
||||
override fun onEditorCellEvents(events: List<EditorCellEvent>) {
|
||||
@@ -275,6 +280,21 @@ class NotebookCellInlayManager private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun addBelowLastCellInlay() { // PY-77218
|
||||
belowLastCellInlay = editor.addComponentInlay(
|
||||
NotebookBelowLastCellPanel(editor),
|
||||
isRelatedToPrecedingText = true,
|
||||
showAbove = false,
|
||||
priority = 0,
|
||||
offset = editor.document.getLineEndOffset((editor.document.lineCount - 1).coerceAtLeast(0))
|
||||
)
|
||||
}
|
||||
|
||||
fun removeBelowLastCellInlay() {
|
||||
belowLastCellInlay?.dispose()
|
||||
belowLastCellInlay = null
|
||||
}
|
||||
|
||||
private fun setupFoldingListener() {
|
||||
val foldingModel = editor.foldingModel
|
||||
foldingModel.addListener(object : FoldingListener {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.intellij.notebooks.visualization.ui
|
||||
|
||||
import com.intellij.openapi.application.ReadAction
|
||||
import com.intellij.openapi.application.WriteIntentReadAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.EditorKind
|
||||
|
||||
Reference in New Issue
Block a user