Skip to content

Commit

Permalink
fix(qsync): Uncaught exception in QuerySyncHighlightingResetListener (#…
Browse files Browse the repository at this point in the history
…7110)

(cherry picked from commit c1a2aff)
  • Loading branch information
Tomasz Pasternak authored and mai93 committed Dec 4, 2024
1 parent 207c13c commit 1efcb55
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.google.idea.blaze.qsync.QuerySyncProjectSnapshot;
import com.intellij.codeInsight.daemon.impl.analysis.FileHighlightingSettingListener;
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingSettingsPerFile;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
Expand All @@ -21,13 +23,18 @@ public class QuerySyncHighlightingResetListener implements QuerySyncProjectListe
@Override
public void onNewProjectSnapshot(Context<?> context, QuerySyncProjectSnapshot instance) {
for (VirtualFile virtualFile : FileEditorManager.getInstance(project).getOpenFiles()) {
var psiFile = PsiManager.getInstance(project).findFile(virtualFile);
if (psiFile != null) {
var newHighlighting = HighlightingSettingsPerFile.getInstance(project).getHighlightingSettingForRoot(psiFile);
project.getMessageBus()
.syncPublisher(FileHighlightingSettingListener.SETTING_CHANGE)
.settingChanged(psiFile, newHighlighting);
}
ApplicationManager.getApplication().invokeLater(() -> WriteAction.run(() -> {
var psiFile = PsiManager.getInstance(project).findFile(virtualFile);
if (psiFile != null) {
var newHighlighting = HighlightingSettingsPerFile
.getInstance(project)
.getHighlightingSettingForRoot(psiFile);
project.getMessageBus()
.syncPublisher(FileHighlightingSettingListener.SETTING_CHANGE)
.settingChanged(psiFile, newHighlighting);
}
}
));
}
}

Expand Down

0 comments on commit 1efcb55

Please sign in to comment.