mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
diff: disable "annotate previous revision" for slave-side lines in Unified Viewer
This commit is contained in:
@@ -17,6 +17,7 @@ package com.intellij.openapi.localVcs;
|
||||
|
||||
public interface UpToDateLineNumberProvider {
|
||||
int ABSENT_LINE_NUMBER = -1;
|
||||
int FAKE_LINE_NUMBER = -2;
|
||||
|
||||
int getLineNumber(int currentNumber);
|
||||
boolean isLineChanged(int currentNumber);
|
||||
|
||||
+2
-2
@@ -503,12 +503,12 @@ public class AnnotateDiffViewerAction extends ToggleAction implements DumbAware
|
||||
@Override
|
||||
public int getLineNumber(int currentNumber) {
|
||||
int number = myViewer.transferLineFromOnesideStrict(mySide, currentNumber);
|
||||
return number != -1 ? myLocalChangesProvider.getLineNumber(number) : -1;
|
||||
return number != -1 ? myLocalChangesProvider.getLineNumber(number) : FAKE_LINE_NUMBER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLineChanged(int currentNumber) {
|
||||
return getLineNumber(currentNumber) == -1;
|
||||
return getLineNumber(currentNumber) == ABSENT_LINE_NUMBER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@ package com.intellij.openapi.vcs.actions;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
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;
|
||||
@@ -53,7 +54,7 @@ class AnnotatePreviousRevisionAction extends AnnotateRevisionAction {
|
||||
@Nullable
|
||||
@Override
|
||||
protected VcsFileRevision getFileRevision(@NotNull AnActionEvent e) {
|
||||
if (getCurrentLine() == -1) {
|
||||
if (getCurrentLine() == UpToDateLineNumberProvider.ABSENT_LINE_NUMBER) {
|
||||
return myLastRevision;
|
||||
}
|
||||
return super.getFileRevision(e);
|
||||
|
||||
+11
-7
@@ -40,31 +40,31 @@ public class AnnotationGutterLineConvertorProxy implements ActiveAnnotationGutte
|
||||
|
||||
public String getLineText(int line, Editor editor) {
|
||||
int currentLine = myGetUpToDateLineNumber.getLineNumber(line);
|
||||
if (currentLine == UpToDateLineNumberProvider.ABSENT_LINE_NUMBER) return "";
|
||||
if (!canBeAnnotated(currentLine)) return "";
|
||||
return myDelegate.getLineText(currentLine, editor);
|
||||
}
|
||||
|
||||
public String getToolTip(int line, Editor editor) {
|
||||
int currentLine = myGetUpToDateLineNumber.getLineNumber(line);
|
||||
if (currentLine == UpToDateLineNumberProvider.ABSENT_LINE_NUMBER) return "";
|
||||
if (!canBeAnnotated(currentLine)) return "";
|
||||
return myDelegate.getToolTip(currentLine, editor);
|
||||
}
|
||||
|
||||
public EditorFontType getStyle(int line, Editor editor) {
|
||||
int currentLine = myGetUpToDateLineNumber.getLineNumber(line);
|
||||
if (currentLine == UpToDateLineNumberProvider.ABSENT_LINE_NUMBER) return EditorFontType.PLAIN;
|
||||
if (!canBeAnnotated(currentLine)) return EditorFontType.PLAIN;
|
||||
return myDelegate.getStyle(currentLine, editor);
|
||||
}
|
||||
|
||||
public ColorKey getColor(int line, Editor editor) {
|
||||
int currentLine = myGetUpToDateLineNumber.getLineNumber(line);
|
||||
if (currentLine == UpToDateLineNumberProvider.ABSENT_LINE_NUMBER) return AnnotationSource.LOCAL.getColor();
|
||||
if (!canBeAnnotated(currentLine)) return AnnotationSource.LOCAL.getColor();
|
||||
return myDelegate.getColor(currentLine, editor);
|
||||
}
|
||||
|
||||
public Color getBgColor(int line, Editor editor) {
|
||||
int currentLine = myGetUpToDateLineNumber.getLineNumber(line);
|
||||
if (currentLine == UpToDateLineNumberProvider.ABSENT_LINE_NUMBER) return null;
|
||||
if (!canBeAnnotated(currentLine)) return null;
|
||||
return myDelegate.getBgColor(currentLine, editor);
|
||||
}
|
||||
|
||||
@@ -78,13 +78,17 @@ public class AnnotationGutterLineConvertorProxy implements ActiveAnnotationGutte
|
||||
|
||||
public void doAction(int lineNum) {
|
||||
int currentLine = myGetUpToDateLineNumber.getLineNumber(lineNum);
|
||||
if (currentLine == UpToDateLineNumberProvider.ABSENT_LINE_NUMBER) return;
|
||||
if (!canBeAnnotated(currentLine)) return;
|
||||
myDelegate.doAction(currentLine);
|
||||
}
|
||||
|
||||
public Cursor getCursor(int lineNum) {
|
||||
int currentLine = myGetUpToDateLineNumber.getLineNumber(lineNum);
|
||||
if (currentLine == UpToDateLineNumberProvider.ABSENT_LINE_NUMBER) return Cursor.getDefaultCursor();
|
||||
if (!canBeAnnotated(currentLine)) return Cursor.getDefaultCursor();
|
||||
return myDelegate.getCursor(currentLine);
|
||||
}
|
||||
|
||||
private static boolean canBeAnnotated(int currentLine) {
|
||||
return currentLine >= 0;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -20,6 +20,7 @@ import com.intellij.openapi.localVcs.UpToDateLineNumberProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.ex.LineStatusTracker;
|
||||
import com.intellij.openapi.vcs.ex.Range;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -104,8 +105,7 @@ public class UpToDateLineNumberProviderImpl implements UpToDateLineNumberProvide
|
||||
return content;
|
||||
}
|
||||
|
||||
private static int calcLineNumber(LineStatusTracker tracker, int currentNumber){
|
||||
if (tracker == null) return -1;
|
||||
private static int calcLineNumber(@NotNull LineStatusTracker tracker, int currentNumber) {
|
||||
List<Range> ranges = tracker.getRanges();
|
||||
int result = currentNumber;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user