Skip to content

Commit

Permalink
fix: run more UI refreshes async & in read action
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiandoetsch committed Mar 20, 2024
1 parent 09fe662 commit 0ec30a6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.snyk.plugin.services

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ReadAction
import com.intellij.openapi.application.invokeLater
import com.intellij.openapi.components.Service
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.fileEditor.FileDocumentManager
Expand Down Expand Up @@ -153,7 +155,7 @@ class SnykTaskQueueService(val project: Project) {
}
}
logger.debug("Container scan completed")
refreshAnnotationsForOpenFiles(project)
invokeLater { refreshAnnotationsForOpenFiles(project) }
}
})
}
Expand Down Expand Up @@ -228,7 +230,7 @@ class SnykTaskQueueService(val project: Project) {
ossResult.getFirstError()?.let { scanPublisher?.scanningOssError(it) }
}
}
refreshAnnotationsForOpenFiles(project)
invokeLater { refreshAnnotationsForOpenFiles(project) }
}
})
}
Expand Down Expand Up @@ -271,7 +273,7 @@ class SnykTaskQueueService(val project: Project) {
}
}
logger.debug("IaC scan completed")
refreshAnnotationsForOpenFiles(project)
invokeLater { refreshAnnotationsForOpenFiles(project) }
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,10 @@ class SnykToolWindowPanel(val project: Project) : JPanel(), Disposable {
}
}

refreshAnnotationsForOpenFiles(project)

ApplicationManager.getApplication().invokeLater {
doCleanUi(true)
refreshAnnotationsForOpenFiles(project)
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/snyk/common/AnnotatorCommon.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package snyk.common

import com.intellij.openapi.application.invokeLater
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiFile
Expand Down Expand Up @@ -33,7 +34,7 @@ object AnnotatorCommon {
SnykProductsOrSeverityListener.SNYK_ENABLEMENT_TOPIC,
object : SnykProductsOrSeverityListener {
override fun enablementChanged() {
refreshAnnotationsForOpenFiles(project)
invokeLater { refreshAnnotationsForOpenFiles(project) }
}
}
)
Expand All @@ -42,7 +43,7 @@ object AnnotatorCommon {
SnykSettingsListener.SNYK_SETTINGS_TOPIC,
object : SnykSettingsListener {
override fun settingsChanged() {
refreshAnnotationsForOpenFiles(project)
invokeLater { refreshAnnotationsForOpenFiles(project) }
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class ContainerBulkFileListener : SnykBulkFileListener() {
snykCachedResults.currentContainerResult = newContainerCache
ApplicationManager.getApplication().invokeLater {
getSnykToolWindowPanel(project)?.displayContainerResults(newContainerCache)
refreshAnnotationsForOpenFiles(project)
}
refreshAnnotationsForOpenFiles(project)
}

private fun makeObsolete(containerIssuesForImage: ContainerIssuesForImage): ContainerIssuesForImage =
Expand Down

0 comments on commit 0ec30a6

Please sign in to comment.