[DataSpell] [DS-7104] [PY-83552] Move the PythonCellSelectionModelProvider to the module which it belongs to

This was placed in the DataSpell module, what broke the consistency. Because of that, it was not possible to move the tests into the different module

(cherry picked from commit 6904ceacab066ed3bc7b76297c3d3fec25a6d386)

GitOrigin-RevId: 1dbe1d2be235b414fa5a9a71882656c74c8f6e44
This commit is contained in:
Alex Plate
2025-08-21 14:05:40 +03:00
committed by intellij-monorepo-bot
parent 5aa12d48e8
commit d670b6e3d4
2 changed files with 9 additions and 0 deletions

View File

@@ -102,6 +102,8 @@
<notebookCellSelfManagedController
implementation="com.intellij.notebooks.visualization.ui.cell.runCell.EditorCellRunGutterControllerFactory"/>
<notebookCellSelectionModelProvider language="Python"
implementationClass="com.intellij.notebooks.visualization.PythonCellSelectionModelProvider"/>
</extensions>
<extensions defaultExtensionNs="org.intellij.markdown">

View File

@@ -1,3 +1,4 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.notebooks.visualization
import com.intellij.openapi.application.ReadAction
@@ -7,6 +8,12 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.LogicalPosition
import kotlin.math.min
class PythonCellSelectionModelProvider : NotebookCellSelectionModelProvider {
override fun create(editor: Editor): NotebookCellSelectionModel =
CaretBasedCellSelectionModel(editor)
}
class CaretBasedCellSelectionModel(private val editor: Editor) : NotebookCellSelectionModel {
override val primarySelectedCell: NotebookCellLines.Interval
get() = editor.getCell(editor.caretModel.primaryCaret.logicalPosition.line)