diff options
| author | Kyren223 <ulmliad223@gmail.com> | 2024-08-23 00:31:20 +0300 |
|---|---|---|
| committer | Kyren223 <ulmliad223@gmail.com> | 2024-08-23 00:32:15 +0300 |
| commit | 7451f83d6685073d10df9bae5c957fdb55dcdc53 (patch) | |
| tree | db9a10dcb117263aebcf03b74b5ad68d466d5287 /src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt | |
| parent | 43346334c56e47e619d40108a07dd8dc651b11fd (diff) | |
fix: issues with IdeaVim version 2.16.0, everything should work now
Diffstat (limited to 'src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt')
| -rw-r--r-- | src/main/kotlin/me/kyren223/trident/actions/TridentSelectAction.kt | 88 |
1 files changed, 44 insertions, 44 deletions
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"
+ }
+}
+
|
