mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: fix "Annotate [Previous|Current] Revision" from annotations for locally modified files
convert line number using LineStatusTracker
This commit is contained in:
+4
-2
@@ -1,6 +1,7 @@
|
||||
package com.intellij.openapi.vcs.actions;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.localVcs.UpToDateLineNumberProvider;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.annotate.FileAnnotation;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
@@ -16,9 +17,10 @@ import java.util.Map;
|
||||
class AnnotateCurrentRevisionAction extends AnnotateRevisionAction {
|
||||
@Nullable private final List<VcsFileRevision> myRevisions;
|
||||
|
||||
public AnnotateCurrentRevisionAction(@NotNull FileAnnotation annotation, @NotNull AbstractVcs vcs) {
|
||||
public AnnotateCurrentRevisionAction(@NotNull UpToDateLineNumberProvider getUpToDateLineNumber,
|
||||
@NotNull FileAnnotation annotation, @NotNull AbstractVcs vcs) {
|
||||
super("Annotate Revision", "Annotate selected revision in new tab", AllIcons.Actions.Annotate,
|
||||
annotation, vcs);
|
||||
getUpToDateLineNumber, annotation, vcs);
|
||||
List<VcsFileRevision> revisions = annotation.getRevisions();
|
||||
if (revisions == null) {
|
||||
myRevisions = null;
|
||||
|
||||
+4
-2
@@ -1,6 +1,7 @@
|
||||
package com.intellij.openapi.vcs.actions;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.localVcs.UpToDateLineNumberProvider;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.annotate.FileAnnotation;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
@@ -16,9 +17,10 @@ import java.util.Map;
|
||||
class AnnotatePreviousRevisionAction extends AnnotateRevisionAction {
|
||||
@Nullable private final List<VcsFileRevision> myRevisions;
|
||||
|
||||
public AnnotatePreviousRevisionAction(@NotNull FileAnnotation annotation, @NotNull AbstractVcs vcs) {
|
||||
public AnnotatePreviousRevisionAction(@NotNull UpToDateLineNumberProvider getUpToDateLineNumber,
|
||||
@NotNull FileAnnotation annotation, @NotNull AbstractVcs vcs) {
|
||||
super("Annotate Previous Revision", "Annotate successor of selected revision in new tab", AllIcons.Actions.Annotate,
|
||||
annotation, vcs);
|
||||
getUpToDateLineNumber, annotation, vcs);
|
||||
List<VcsFileRevision> revisions = annotation.getRevisions();
|
||||
if (revisions == null) {
|
||||
myRevisions = null;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.intellij.openapi.vcs.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.localVcs.UpToDateLineNumberProvider;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
@@ -19,14 +20,18 @@ import javax.swing.*;
|
||||
import java.util.List;
|
||||
|
||||
abstract class AnnotateRevisionAction extends AnnotateRevisionActionBase implements DumbAware, LineNumberListener {
|
||||
private final UpToDateLineNumberProvider myGetUpToDateLineNumber;
|
||||
|
||||
@NotNull private final FileAnnotation myAnnotation;
|
||||
@NotNull private final AbstractVcs myVcs;
|
||||
|
||||
private int currentLine;
|
||||
|
||||
public AnnotateRevisionAction(@Nullable String text, @Nullable String description, @Nullable Icon icon,
|
||||
@NotNull UpToDateLineNumberProvider getUpToDateLineNumber,
|
||||
@NotNull FileAnnotation annotation, @NotNull AbstractVcs vcs) {
|
||||
super(text, description, icon);
|
||||
myGetUpToDateLineNumber = getUpToDateLineNumber;
|
||||
myAnnotation = annotation;
|
||||
myVcs = vcs;
|
||||
}
|
||||
@@ -67,8 +72,11 @@ abstract class AnnotateRevisionAction extends AnnotateRevisionActionBase impleme
|
||||
List<VcsFileRevision> revisions = getRevisions();
|
||||
assert getRevisions() != null;
|
||||
|
||||
if (currentLine < 0 || currentLine >= revisions.size()) return null;
|
||||
return revisions.get(currentLine);
|
||||
if (currentLine < 0) return null;
|
||||
int corrected = myGetUpToDateLineNumber.getLineNumber(currentLine);
|
||||
|
||||
if (corrected < 0 || corrected >= revisions.size()) return null;
|
||||
return revisions.get(corrected);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -299,8 +299,8 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware, Ann
|
||||
presentation.addAction(actionGroup, 1);
|
||||
gutters.add(new ExtraFieldGutter(fileAnnotation, editor, presentation, bgColorMap, actionGroup));
|
||||
|
||||
presentation.addAction(new AnnotateCurrentRevisionAction(fileAnnotation, vcs));
|
||||
presentation.addAction(new AnnotatePreviousRevisionAction(fileAnnotation, vcs));
|
||||
presentation.addAction(new AnnotateCurrentRevisionAction(getUpToDateLineNumber, fileAnnotation, vcs));
|
||||
presentation.addAction(new AnnotatePreviousRevisionAction(getUpToDateLineNumber, fileAnnotation, vcs));
|
||||
addActionsFromExtensions(presentation, fileAnnotation);
|
||||
|
||||
for (AnAction action : presentation.getActions()) {
|
||||
|
||||
Reference in New Issue
Block a user