From 58e0c204a4af70e63c41e74f931d5ffb8b075901 Mon Sep 17 00:00:00 2001 From: kamild Date: Mon, 21 Oct 2024 22:27:36 +0200 Subject: [PATCH] fix OpenNewConsoleWithSelectionAction --- .../action/OpenNewConsoleWithSelectionAction.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/action/OpenNewConsoleWithSelectionAction.kt b/src/main/kotlin/nl/deschepers/laraveltinker/action/OpenNewConsoleWithSelectionAction.kt index 47c0eb6..a3cb357 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/action/OpenNewConsoleWithSelectionAction.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/action/OpenNewConsoleWithSelectionAction.kt @@ -3,10 +3,9 @@ package nl.deschepers.laraveltinker.action import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.actionSystem.CommonDataKeys +import com.intellij.openapi.actionSystem.PlatformDataKeys import com.intellij.openapi.editor.Editor import com.intellij.openapi.fileEditor.FileEditorManager -import com.intellij.openapi.vfs.VirtualFile import com.jetbrains.php.lang.PhpFileType import nl.deschepers.laraveltinker.Strings import nl.deschepers.laraveltinker.util.TinkerConsoleUtil @@ -18,10 +17,9 @@ class OpenNewConsoleWithSelectionAction : AnAction() { e.presentation.isVisible = false e.presentation.isEnabled = true e.presentation.text = Strings.get("lt.menu.action.open_new_console_with_selection") - val currentEditor: Editor = e.getData(CommonDataKeys.EDITOR) ?: return - val virtualFile: VirtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE) ?: return + val currentEditor: Editor = e.getData(PlatformDataKeys.EDITOR) ?: return - if (virtualFile.fileType is PhpFileType && currentEditor.selectionModel.hasSelection()) { + if (currentEditor.virtualFile.fileType is PhpFileType && currentEditor.selectionModel.hasSelection()) { e.presentation.isVisible = true } } @@ -29,7 +27,7 @@ class OpenNewConsoleWithSelectionAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { val project = e.project ?: return val tinkerConsoleUtil = TinkerConsoleUtil(project) - val currentEditor: Editor = e.getData(CommonDataKeys.EDITOR) ?: return + val currentEditor: Editor = e.getData(PlatformDataKeys.EDITOR) ?: return if (currentEditor.selectionModel.hasSelection()) { val tinkerConsole =