diff options
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 |
