@@ -6,10 +6,12 @@ import com.intellij.openapi.fileEditor.FileEditorManager
66import com.intellij.openapi.project.Project
77import com.intellij.openapi.rd.util.withUiContext
88import com.intellij.openapi.vfs.VirtualFile
9+ import org.apache.commons.collections4.CollectionUtils
910import org.digma.intellij.plugin.common.Backgroundable
1011import org.digma.intellij.plugin.document.DocumentInfoContainer
1112import org.digma.intellij.plugin.document.DocumentInfoService
1213import org.digma.intellij.plugin.log.Log
14+ import org.digma.intellij.plugin.model.rest.insights.CodeObjectInsight
1315import org.digma.intellij.plugin.ui.model.MethodScope
1416import org.digma.intellij.plugin.ui.service.ErrorsViewService
1517import org.digma.intellij.plugin.ui.service.InsightsViewService
@@ -75,11 +77,27 @@ class RefreshService(private val project: Project) {
7577
7678 private fun updateInsightsCacheForActiveDocument (selectedTextEditor : Editor ? , documentInfoContainer : DocumentInfoContainer ? , scope : MethodScope ) {
7779 val selectedDocument = selectedTextEditor?.document
78- if (selectedDocument != null ) {
79- documentInfoContainer?.updateCache()
80+ if (selectedDocument != null && documentInfoContainer != null ) {
81+ val oldInsights = documentInfoContainer.allInsights
82+
83+ documentInfoContainer.updateCache()
84+
85+ val newInsights = documentInfoContainer.allInsights
86+
87+ // refresh the UI ONLY if newInsights list is different from oldInsights
88+ if (dataChanged(oldInsights, newInsights)) {
89+ insightsViewService.updateInsightsModel(scope.getMethodInfo())
90+ errorsViewService.updateErrorsModel(scope.getMethodInfo())
91+ }
8092 }
81- insightsViewService.updateInsightsModel(scope.getMethodInfo())
82- errorsViewService.updateErrorsModel(scope.getMethodInfo())
93+ }
94+
95+ private fun dataChanged (oldInsights : List <CodeObjectInsight ?>, newInsights : List <CodeObjectInsight ?>): Boolean {
96+ val isEqual = CollectionUtils .isEqualCollection(
97+ oldInsights,
98+ newInsights
99+ )
100+ return ! isEqual
83101 }
84102
85103 private fun notifyRefreshInsightsTaskStarted (fileUri : String? ) {
0 commit comments