@@ -2,6 +2,8 @@ package com.github.lppedd.cc.configuration
22
33import com.github.lppedd.cc.CC
44import com.github.lppedd.cc.CCBundle
5+ import com.github.lppedd.cc.invokeLaterOnEdt
6+ import com.intellij.openapi.application.ApplicationManager
57import com.intellij.openapi.diagnostic.logger
68import com.intellij.openapi.options.SearchableConfigurable
79import com.intellij.openapi.project.Project
@@ -36,20 +38,25 @@ internal class CCMainConfigurable(private val project: Project) : SearchableConf
3638 gui.customTokensFilePath = configService.customFilePath
3739 gui.customCoAuthorsFilePath = configService.customCoAuthorsFilePath
3840
39- val tokensService = CCTokensService .getInstance(project)
40- val tokens = when (val result = tokensService.getTokens()) {
41- is TokensResult .Success -> result.tokens
42- is TokensResult .FileError -> {
43- logger.debug(" Error while getting tokens" , result.message)
44- tokensService.getBundledTokens()
41+ ApplicationManager .getApplication().executeOnPooledThread {
42+ val tokensService = CCTokensService .getInstance(project)
43+ val tokens = when (val result = tokensService.getTokens()) {
44+ is TokensResult .Success -> result.tokens
45+ is TokensResult .FileError -> {
46+ logger.debug(" Error while getting tokens" , result.message)
47+ tokensService.getBundledTokens()
48+ }
49+ is TokensResult .SchemaError -> {
50+ logger.debug(" Error while getting tokens" , result.failure)
51+ tokensService.getBundledTokens()
52+ }
4553 }
46- is TokensResult . SchemaError -> {
47- logger.debug( " Error while getting tokens " , result.failure)
48- tokensService.getBundledTokens( )
54+
55+ invokeLaterOnEdt {
56+ gui.setTokens(tokens.types )
4957 }
5058 }
5159
52- gui.setTokens(tokens.types)
5360 return gui.rootPanel
5461 }
5562
@@ -74,16 +81,22 @@ internal class CCMainConfigurable(private val project: Project) : SearchableConf
7481 configService.customCoAuthorsFilePath = gui.customCoAuthorsFilePath
7582 configService.customFilePath = gui.customTokensFilePath
7683
77- val tokensService = CCTokensService .getInstance(project)
78- when (val result = tokensService.getTokens()) {
79- is TokensResult .Success -> gui.setTokens(result.tokens.types)
80- is TokensResult .FileError -> {
81- logger.debug(" Error while getting tokens" , result.message)
82- gui.revalidate()
83- }
84- is TokensResult .SchemaError -> {
85- logger.debug(" Error while getting tokens" , result.failure)
86- gui.revalidate()
84+ ApplicationManager .getApplication().executeOnPooledThread {
85+ val tokensService = CCTokensService .getInstance(project)
86+ val result = tokensService.getTokens()
87+
88+ invokeLaterOnEdt {
89+ when (result) {
90+ is TokensResult .Success -> gui.setTokens(result.tokens.types)
91+ is TokensResult .FileError -> {
92+ logger.debug(" Error while getting tokens" , result.message)
93+ gui.revalidate()
94+ }
95+ is TokensResult .SchemaError -> {
96+ logger.debug(" Error while getting tokens" , result.failure)
97+ gui.revalidate()
98+ }
99+ }
87100 }
88101 }
89102
0 commit comments