From 7451f83d6685073d10df9bae5c957fdb55dcdc53 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Fri, 23 Aug 2024 00:31:20 +0300 Subject: fix: issues with IdeaVim version 2.16.0, everything should work now --- .../trident/actions/TridentSelectAction.kt | 88 +++++++++++----------- 1 file changed, 44 insertions(+), 44 deletions(-) (limited to 'src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt') diff --git a/src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt b/src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt index 60973f2..2eeada3 100644 --- a/src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt +++ b/src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt @@ -1,44 +1,44 @@ -package me.kyren223.trident.actions - -import com.intellij.openapi.actionSystem.AnAction -import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.actionSystem.PlatformDataKeys -import com.intellij.openapi.fileEditor.FileEditorManager -import me.kyren223.trident.utils.TridentList - -class TridentSelectAction : AnAction() { - override fun actionPerformed(e: AnActionEvent) { - val project = e.project ?: return - val index = when (val actionId = e.actionManager.getId(this)) { - NEXT -> { - val file = e.getData(PlatformDataKeys.VIRTUAL_FILE) ?: return - val current = TridentList.getIndexOfFile(project, file) ?: return - current + 1 - } - - PREV -> { - val file = e.getData(PlatformDataKeys.VIRTUAL_FILE) ?: return - val current = TridentList.getIndexOfFile(project, file) ?: return - current - 1 - } - - else -> { - getIndex(actionId!!) - } - } - - val file = TridentList.select(project, index) ?: return - FileEditorManager.getInstance(project).openFile(file, true) - } - - private fun getIndex(actionId: String): Int { - return actionId.substring(SELECT.length).toInt() - 1 - } - - companion object { - const val NEXT = "TridentSelectNext" - const val PREV = "TridentSelectPrev" - const val SELECT = "TridentSelect" - } -} - +package me.kyren223.trident.actions + +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.PlatformDataKeys +import com.intellij.openapi.fileEditor.FileEditorManager +import me.kyren223.trident.utils.TridentList + +class TridentSelectAction : AnAction() { + override fun actionPerformed(e: AnActionEvent) { + val project = e.project ?: return + val index = when (val actionId = e.actionManager.getId(this)) { + NEXT -> { + val file = e.getData(PlatformDataKeys.VIRTUAL_FILE) ?: return + val current = TridentList.getIndexOfFile(project, file) ?: return + current + 1 + } + + PREV -> { + val file = e.getData(PlatformDataKeys.VIRTUAL_FILE) ?: return + val current = TridentList.getIndexOfFile(project, file) ?: return + current - 1 + } + + else -> { + getIndex(actionId!!) + } + } + + val file = TridentList.select(project, index) ?: return + FileEditorManager.getInstance(project).openFile(file, true) + } + + private fun getIndex(actionId: String): Int { + return actionId.substring(SELECT.length).toInt() - 1 + } + + companion object { + const val NEXT = "TridentSelectNext" + const val PREV = "TridentSelectPrev" + const val SELECT = "TridentSelect" + } +} + -- cgit v1.3.1