PY-80672 Jupyter: Refactor New Cell Action remove dublicates

(cherry picked from commit 05180d5b5cc1cff6283ff3987ebb01d7d276a12e)

GitOrigin-RevId: 9ee5f1268424a862eeb9f5f8a0807c6a777432e3
This commit is contained in:
Nikita.Ashihmin
2025-04-30 17:33:25 +04:00
committed by intellij-monorepo-bot
parent 7bf40f525b
commit 9e329b27af
8 changed files with 14 additions and 5 deletions

View File

@@ -58,6 +58,7 @@ class NotebookBelowLastCellPanel(
}
companion object {
@Language("devkit-action-id") private const val ACTION_GROUP_ID = "Jupyter.BelowCellNewPanel"
@Language("devkit-action-id")
private const val ACTION_GROUP_ID = "Jupyter.CreateNewCellsPanel"
}
}

View File

@@ -53,6 +53,7 @@ class NotebookCellInlayManager private constructor(
}
override fun dispose() {
views.clear()
editor.removeUserData(CELL_INLAY_MANAGER_KEY)
}

View File

@@ -11,6 +11,7 @@ object EditorCellDataContext {
fun createContextProvider(editorCell: EditorCell, component: JComponent): JComponent {
return UiDataProvider.wrapComponent(component) { sink ->
sink[NotebookDataContext.NOTEBOOK_CELL_LINES_INTERVAL] = editorCell.intervalOrNull
sink[NotebookDataContext.SHOW_TEXT] = true
sink[PlatformCoreDataKeys.CONTEXT_COMPONENT] = component
sink[PlatformDataKeys.EDITOR] = editorCell.editor
}

View File

@@ -11,6 +11,8 @@ import com.intellij.openapi.editor.impl.EditorImpl
object NotebookDataContext {
val NOTEBOOK_CELL_LINES_INTERVAL: DataKey<NotebookCellLines.Interval> = DataKey.create("NOTEBOOK_CELL_LINES_INTERVAL")
val NOTEBOOK_CELL_INSERT_ABOVE: DataKey<Boolean> = DataKey.create("NOTEBOOK_CELL_INSERT_ABOVE")
val SHOW_TEXT: DataKey<Boolean> = DataKey.create("SHOW_ACTION_TEXT")
val NOTEBOOK_CELL_OUTPUT_DATA_KEY: DataKey<EditorCellOutput> = DataKey.create("NOTEBOOK_CELL_OUTPUT")

View File

@@ -49,6 +49,7 @@ class EditorNotebook(val editor: EditorImpl) : Disposable {
}, this)
}
@Suppress("UNCHECKED_CAST")
fun <T : EditorNotebookExtension> getExtension(cls: KClass<T>): T? {
return extensions[cls] as? T

View File

@@ -17,6 +17,7 @@ internal data class NotebookCellDataProvider(
override fun getData(key: String): Any? =
when (key) {
NotebookDataContext.NOTEBOOK_CELL_LINES_INTERVAL.name -> intervalProvider()
NotebookDataContext.NOTEBOOK_CELL_INSERT_ABOVE.name -> false
PlatformCoreDataKeys.CONTEXT_COMPONENT.name -> component
PlatformDataKeys.EDITOR.name -> editor
else -> null

View File

@@ -4,7 +4,7 @@ package com.intellij.notebooks.visualization.ui.endInlay.addToolbar
import com.intellij.notebooks.ui.visualization.NotebookUtil.notebookAppearance
import com.intellij.notebooks.visualization.NotebookBelowLastCellPanel
import com.intellij.notebooks.visualization.NotebookCellInlayManager
import com.intellij.notebooks.visualization.context.NotebookDataContext.NOTEBOOK_CELL_LINES_INTERVAL
import com.intellij.notebooks.visualization.context.NotebookDataContext
import com.intellij.notebooks.visualization.ui.addComponentInlay
import com.intellij.notebooks.visualization.ui.cellsDnD.DropHighlightable
import com.intellij.notebooks.visualization.ui.endInlay.EditorNotebookEndInlay
@@ -20,7 +20,9 @@ class EditorNotebookEndAddToolbar(val inlayManager: NotebookCellInlayManager) :
// PY-77218
editor.addComponentInlay(
UiDataProvider.wrapComponent(belowLastCellPanel) { sink ->
sink[NOTEBOOK_CELL_LINES_INTERVAL] = inlayManager.notebook.cells.lastOrNull()?.interval
sink[NotebookDataContext.NOTEBOOK_CELL_LINES_INTERVAL] = inlayManager.notebook.cells.lastOrNull()?.interval
sink[NotebookDataContext.SHOW_TEXT] = true
sink[NotebookDataContext.NOTEBOOK_CELL_INSERT_ABOVE] = false
},
isRelatedToPrecedingText = true,
showAbove = false,

View File

@@ -128,8 +128,8 @@ public abstract class KeymapsTestCase extends KeymapsTestCaseBase {
"CodeFloatingToolbar.GotoPrevMenu"},
{"shift UP", "EditorUpWithSelection", "JupyterExpandSelectionToCellAboveCommandModeAction"},
{"shift V", "Graph.DistributeNodes.Vertically", "JupyterNotebookPasteCellAboveCommandModeAction"},
{"shift alt A", "NotebookInsertCellAboveAction", "VcsHistory.ShowAllAffected"},
{"shift alt B", "NotebookInsertCellBelowAction", "tasks.open.in.browser", "sql.SelectInDatabaseView"},
{"shift alt A", "NotebookInsertCodeCellAboveAction", "VcsHistory.ShowAllAffected"},
{"shift alt B", "NotebookInsertCodeCellAction", "tasks.open.in.browser", "sql.SelectInDatabaseView"},
{"shift alt ENTER", "AIAssistant.Editor.AcceptMultiLineCompletion", "Console.TableResult.EditValueMaximized", "JupyterDebugAction", "SplitChooser"},
{"shift alt F7", "ForceStepInto", "StepIntoMyCode"},
{"shift alt G", "EditorAddCaretPerSelectedLine", "hg4idea.QGotoFromPatches"},