mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
git: fix annotations not being closed on commit
We can't reuse FileAnnotation after it's been disposed. It's being disposed when annotations are closed, so we should create new one.
This commit is contained in:
@@ -24,6 +24,7 @@ import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.openapi.vcs.vfs.VcsVirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -41,7 +42,7 @@ public abstract class FileAnnotation {
|
||||
@NotNull private final Project myProject;
|
||||
|
||||
private Runnable myCloser;
|
||||
private Runnable myReloader;
|
||||
private Consumer<FileAnnotation> myReloader;
|
||||
|
||||
protected FileAnnotation(@NotNull Project project) {
|
||||
myProject = project;
|
||||
@@ -180,10 +181,14 @@ public abstract class FileAnnotation {
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify that annotation information has changed, and UI should be updated.
|
||||
* Notify that annotation information has changed, and should be updated.
|
||||
* If `this` is visible, hide it and show new one instead.
|
||||
* If `this` is not visible, do nothing.
|
||||
*
|
||||
* @param newFileAnnotation annotations to be shown
|
||||
*/
|
||||
public final void reload() {
|
||||
if (myReloader != null) myReloader.run();
|
||||
public final void reload(@NotNull FileAnnotation newFileAnnotation) {
|
||||
if (myReloader != null) myReloader.consume(newFileAnnotation);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,7 +201,7 @@ public abstract class FileAnnotation {
|
||||
/**
|
||||
* @see #reload()
|
||||
*/
|
||||
public final void setReloader(@Nullable Runnable reloader) {
|
||||
public final void setReloader(@Nullable Consumer<FileAnnotation> reloader) {
|
||||
myReloader = reloader;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.localVcs.UpToDateLineNumberProvider;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
@@ -101,9 +102,10 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware {
|
||||
});
|
||||
});
|
||||
|
||||
fileAnnotation.setReloader(() -> {
|
||||
fileAnnotation.setReloader(newFileAnnotation -> {
|
||||
if (editor.getGutter().isAnnotationsShown()) {
|
||||
doAnnotate(editor, project, currentFile, fileAnnotation, vcs, upToDateLineNumberProvider);
|
||||
assert Comparing.equal(currentFile, newFileAnnotation.getFile());
|
||||
doAnnotate(editor, project, currentFile, newFileAnnotation, vcs, upToDateLineNumberProvider);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -197,8 +197,9 @@ public class GitAnnotationProvider implements AnnotationProviderEx {
|
||||
(revisions) -> {
|
||||
if (revisions == null) return;
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
GitFileAnnotation newFileAnnotation = new GitFileAnnotation(fileAnnotation);
|
||||
fileAnnotation.setRevisions(revisions);
|
||||
fileAnnotation.reload();
|
||||
fileAnnotation.reload(newFileAnnotation);
|
||||
});
|
||||
},
|
||||
ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS
|
||||
|
||||
@@ -87,6 +87,10 @@ public class GitFileAnnotation extends FileAnnotation {
|
||||
myLines = lines;
|
||||
}
|
||||
|
||||
public GitFileAnnotation(@NotNull GitFileAnnotation annotation) {
|
||||
this(annotation.getProject(), annotation.getFile(), annotation.getCurrentRevision(), annotation.getLines());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user