From 4f6266ddefa3a621d1208cc3ff538bf30319aecc Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Tue, 13 Feb 2024 18:07:25 +0200 Subject: Deleted un-needed file, implemented select action, includes prev/next, for prev/next implemented wrap around --- .../kotlin/me/kyren223/harpoonforjb/HarpoonState.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/main/kotlin/me/kyren223/harpoonforjb/HarpoonState.kt') diff --git a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonState.kt b/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonState.kt index 75db721..fcb20a5 100644 --- a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonState.kt +++ b/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonState.kt @@ -6,12 +6,8 @@ import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VirtualFile object HarpoonState { - private var previousIndex: Int? = null - private var currentIndex: Int? = null - private var nextIndex: Int? = null - private var projectFiles: MutableMap> = mutableMapOf() - private val HARPOON_LIST_KEY = "HarpoonList" + private const val HARPOON_LIST_KEY = "HarpoonList" fun setFile(project: Project, index: Int, file: VirtualFile) { if (index < 0) return @@ -66,4 +62,16 @@ object HarpoonState { .toList() properties.setList(HARPOON_LIST_KEY, stringList) } + + fun getIndexOfFile(project: Project, data: VirtualFile?): Int { + loadProject(project) + val files = projectFiles[project.name] + if (files == null || data == null) return -1 + return files.indexOfFirst { it.path == data.path } + } + + fun getFileCount(project: Project): Int { + loadProject(project) + return projectFiles[project.name]!!.size + } } \ No newline at end of file -- cgit v1.3.1