Refresh file presentation after sync - #8407
Conversation
To avoid stile file representations i.e., the sync status, the file status has to be refreshed after every sync.
There was a problem hiding this comment.
Code Review
This pull request introduces a helper method refreshSyncStatusIndicators in ProjectTargetManagerImpl.java to refresh the project view and update the file presentation of all open files during build start and after sync. The reviewer pointed out a potential threading issue, as these UI-related operations might be executed on background threads, and suggested wrapping them in ApplicationManager.getApplication().invokeLater while checking if the project is disposed.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| final var fileEditorManager = FileEditorManager.getInstance(project); | ||
| for (final var file : fileEditorManager.getOpenFiles()) { | ||
| fileEditorManager.updateFilePresentation(file); | ||
| } |
There was a problem hiding this comment.
Updating file presentation and querying open files are UI-related operations. Since refreshSyncStatusIndicators can be called from background threads (e.g., during buildStarted or afterSync), executing these operations directly on the calling thread can lead to CalledInWrongThreadException or threading issues.
It is safer to wrap these operations in ApplicationManager.getApplication().invokeLater(...) and ensure the project is not disposed before executing.
com.intellij.openapi.application.ApplicationManager.getApplication().invokeLater(() -> {
if (project.isDisposed()) {
return;
}
final var fileEditorManager = FileEditorManager.getInstance(project);
for (final var file : fileEditorManager.getOpenFiles()) {
fileEditorManager.updateFilePresentation(file);
}
});There was a problem hiding this comment.
maybe this is a correct finding
| final var fileEditorManager = FileEditorManager.getInstance(project); | ||
| for (final var file : fileEditorManager.getOpenFiles()) { | ||
| fileEditorManager.updateFilePresentation(file); | ||
| } |
There was a problem hiding this comment.
maybe this is a correct finding
To avoid stile file representations i.e., the sync status, the file status has to be refreshed after every sync.
Addresses: https://youtrack.jetbrains.com/issue/CPP-45375