mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 17:20:55 +07:00
PY-72902 Jupyter(fix): fix tests
GitOrigin-RevId: 763ad97d4a759ed215c4232b9ee0881915056a46
This commit is contained in:
committed by
intellij-monorepo-bot
parent
bd060c8869
commit
06871f2f00
@@ -12,7 +12,7 @@ object NotebookDataContext {
|
|||||||
|
|
||||||
val DataContext.notebookEditor: EditorImpl?
|
val DataContext.notebookEditor: EditorImpl?
|
||||||
get() {
|
get() {
|
||||||
val component = getData(PlatformCoreDataKeys.CONTEXT_COMPONENT) ?: return null
|
val component = getData(PlatformCoreDataKeys.CONTEXT_COMPONENT)
|
||||||
val editor = getData(PlatformCoreDataKeys.EDITOR)
|
val editor = getData(PlatformCoreDataKeys.EDITOR)
|
||||||
val noteEditor = NotebookDataContextUtils.getCurrentEditor(editor, component) ?: return null
|
val noteEditor = NotebookDataContextUtils.getCurrentEditor(editor, component) ?: return null
|
||||||
if (NotebookDataContextUtils.hasFocusedSearchReplaceComponent(noteEditor, component))
|
if (NotebookDataContextUtils.hasFocusedSearchReplaceComponent(noteEditor, component))
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.intellij.notebooks.visualization.context
|
|||||||
import com.intellij.find.SearchReplaceComponent
|
import com.intellij.find.SearchReplaceComponent
|
||||||
import com.intellij.ide.IdeEventQueue
|
import com.intellij.ide.IdeEventQueue
|
||||||
import com.intellij.notebooks.visualization.NotebookCellLines
|
import com.intellij.notebooks.visualization.NotebookCellLines
|
||||||
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import com.intellij.openapi.editor.ex.EditorGutterComponentEx
|
import com.intellij.openapi.editor.ex.EditorGutterComponentEx
|
||||||
import com.intellij.openapi.editor.impl.EditorComponentImpl
|
import com.intellij.openapi.editor.impl.EditorComponentImpl
|
||||||
@@ -24,8 +25,14 @@ object NotebookDataContextUtils {
|
|||||||
return mouseEditorOffset
|
return mouseEditorOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (contextComponent!=null) {
|
||||||
|
val calculatedLine = getRespectiveLineNumberInEditor(noteEditor, contextComponent)
|
||||||
|
if (calculatedLine!=null)
|
||||||
|
return calculatedLine
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ApplicationManager.getApplication().isUnitTestMode)
|
||||||
|
return null
|
||||||
val point = editor.contentComponent.mousePosition ?: return null
|
val point = editor.contentComponent.mousePosition ?: return null
|
||||||
val logicalPosition = editor.xyToLogicalPosition(point)
|
val logicalPosition = editor.xyToLogicalPosition(point)
|
||||||
return logicalPosition.line
|
return logicalPosition.line
|
||||||
@@ -52,11 +59,7 @@ object NotebookDataContextUtils {
|
|||||||
return noteEditor
|
return noteEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCaretLine(editor: EditorImpl): Int {
|
private fun getRespectiveLineNumberInEditor(editor: Editor, component: Component): Int? {
|
||||||
return editor.caretModel.logicalPosition.line
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getRespectiveLineNumberInEditor(editor: Editor, component: Component): Int? {
|
|
||||||
val point = SwingUtilities.convertPoint(component, 0, component.height, editor.contentComponent)
|
val point = SwingUtilities.convertPoint(component, 0, component.height, editor.contentComponent)
|
||||||
val documentLineCount = editor.document.lineCount
|
val documentLineCount = editor.document.lineCount
|
||||||
|
|
||||||
@@ -77,7 +80,7 @@ object NotebookDataContextUtils {
|
|||||||
return editor.logicalPositionToOffset(editor.xyToLogicalPosition(point))
|
return editor.logicalPositionToOffset(editor.xyToLogicalPosition(point))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hasFocusedSearchReplaceComponent(editor: Editor, contextComponent: Component): Boolean {
|
fun hasFocusedSearchReplaceComponent(editor: Editor, contextComponent: Component?): Boolean {
|
||||||
val searchReplaceComponent = editor.headerComponent.asSafely<SearchReplaceComponent>() ?: return false
|
val searchReplaceComponent = editor.headerComponent.asSafely<SearchReplaceComponent>() ?: return false
|
||||||
return contextComponent === searchReplaceComponent.searchTextComponent ||
|
return contextComponent === searchReplaceComponent.searchTextComponent ||
|
||||||
contextComponent === searchReplaceComponent.replaceTextComponent
|
contextComponent === searchReplaceComponent.replaceTextComponent
|
||||||
|
|||||||
Reference in New Issue
Block a user