diff options
| author | Kyren223 <ulmliad223@gmail.com> | 2024-02-13 18:07:25 +0200 |
|---|---|---|
| committer | Kyren223 <ulmliad223@gmail.com> | 2024-02-13 18:07:25 +0200 |
| commit | 4f6266ddefa3a621d1208cc3ff538bf30319aecc (patch) | |
| tree | a685da403841d36c2e31e47069adb31a07a9162e /src/main/kotlin/me/kyren223/harpoonforjb/HarpoonState.kt | |
| parent | f5462d7b4b50fe05b98cee3274c26a9b9f52dd93 (diff) | |
Deleted un-needed file, implemented select action, includes prev/next, for prev/next implemented wrap around
Diffstat (limited to 'src/main/kotlin/me/kyren223/harpoonforjb/HarpoonState.kt')
| -rw-r--r-- | src/main/kotlin/me/kyren223/harpoonforjb/HarpoonState.kt | 18 |
1 files changed, 13 insertions, 5 deletions
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<String, MutableList<VirtualFile>> = 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 |
