Changesets · Branches · Tags · Compare
| Changeset | b22d6ac67539234359e709265a889c9e429ff0e735523bb14cee6ebc2cdc5121 |
|---|---|
| Author | Jakub Blach <jakubblach@gmail.com> · 2025-09-26 18:50 +02:00 |
| Committer | Jakub Blach <jakubblach@gmail.com> · 2025-09-26 18:50 +02:00 |
| Parents | 1a75b05c8746 |
1 file changed
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/proxy/ProxyPoolingActivity.kt +10 −7
| @@ -5,20 +5,23 @@ | ||
| 5 | 5 | import com.intellij.openapi.diagnostic.Logger |
| 6 | 6 | import com.intellij.openapi.project.Project |
| 7 | 7 | import com.intellij.openapi.startup.ProjectActivity |
| 8 | -import kotlinx.coroutines.delay | |
| 8 | +import kotlinx.coroutines.* | |
| 9 | 9 | import kotlin.time.Duration.Companion.seconds |
| 10 | 10 | |
| 11 | 11 | class ProxyPoolingActivity : ProjectActivity { |
| 12 | 12 | private var lastSettings = ProxySettings.getSettings() |
| 13 | + private val scope = CoroutineScope(Dispatchers.Default) | |
| 13 | 14 | |
| 14 | 15 | override suspend fun execute(project: Project) { |
| 15 | - while (true) { | |
| 16 | - val newSettings = ProxySettings.getSettings() | |
| 17 | - if (newSettings != lastSettings) { | |
| 18 | - onSettingsChanged(project) | |
| 19 | - lastSettings = newSettings | |
| 16 | + scope.launch { | |
| 17 | + while (isActive) { | |
| 18 | + val newSettings = ProxySettings.getSettings() | |
| 19 | + if (newSettings != lastSettings) { | |
| 20 | + onSettingsChanged(project) | |
| 21 | + lastSettings = newSettings | |
| 22 | + } | |
| 23 | + delay(2.seconds) | |
| 20 | 24 | } |
| 21 | - delay(2.seconds) | |
| 22 | 25 | } |
| 23 | 26 | } |
| 24 | 27 |