Skip to content

Commit

Permalink
SLI-1065 Fix UI freeze when analyzing a file
Browse files Browse the repository at this point in the history
  • Loading branch information
damien-urruty-sonarsource committed Aug 28, 2023
1 parent 768498d commit ffd5649
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
package org.sonarlint.intellij.analysis

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.fileEditor.FileEditorManagerEvent
import com.intellij.openapi.fileEditor.FileEditorManagerListener
Expand All @@ -41,7 +40,6 @@ class OnTheFlyFindingsHolder(private val project: Project) : FileEditorManagerLi
private val currentSecurityHotspotsPerOpenFile: MutableMap<VirtualFile, Collection<LiveSecurityHotspot>> = ConcurrentHashMap()

init {
ApplicationManager.getApplication().invokeAndWait { selectedFile = SonarLintUtils.getSelectedFile(project) }
project.messageBus.connect()
.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, this)
}
Expand All @@ -57,6 +55,9 @@ class OnTheFlyFindingsHolder(private val project: Project) : FileEditorManagerLi
currentIssuesPerOpenFile.putAll(issuesPerFile)
currentSecurityHotspotsPerOpenFile.putAll(securityHotspotsPerFile)
runOnUiThread(project) {
if (selectedFile == null) {
selectedFile = SonarLintUtils.getSelectedFile(project)
}
if (issuesPerFile.keys.contains(selectedFile)) {
updateCurrentFileTab()
}
Expand Down Expand Up @@ -95,6 +96,9 @@ class OnTheFlyFindingsHolder(private val project: Project) : FileEditorManagerLi
}

fun clearCurrentFile() {
if (selectedFile == null) {
selectedFile = SonarLintUtils.getSelectedFile(project)
}
if (selectedFile != null) {
currentIssuesPerOpenFile.remove(selectedFile)
}
Expand Down

0 comments on commit ffd5649

Please sign in to comment.