Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix OpenNewConsoleWithSelectionAction #373

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,18 +17,17 @@ 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
}
}

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 =
Expand Down