[vcs-log] try to prevent index out of bounds from completely breaking the log

This commit is contained in:
Julia Beliaeva
2015-05-12 16:57:05 +03:00
parent 0328cdf8fc
commit 74ddf35d02
@@ -18,6 +18,7 @@ package com.intellij.vcs.log.ui.frame;
import com.intellij.icons.AllIcons;
import com.intellij.ide.CopyProvider;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.util.Couple;
import com.intellij.openapi.util.Pair;
@@ -69,6 +70,7 @@ import java.util.*;
import java.util.List;
public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, CopyProvider {
private static final Logger LOG = Logger.getInstance(VcsLogGraphTable.class);
public static final int ROOT_INDICATOR_COLORED_WIDTH = 8;
public static final int ROOT_INDICATOR_WHITE_WIDTH = 5;
@@ -336,9 +338,16 @@ public class VcsLogGraphTable extends JBTable implements TypeSafeDataProvider, C
}
private VcsLogHighlighter.VcsCommitStyle getStyle(int row, int column, String text, boolean hasFocus, final boolean selected) {
final RowInfo<Integer> rowInfo = myDataPack.getVisibleGraph().getRowInfo(row);
Component dummyRendererComponent = myDummyRenderer.getTableCellRendererComponent(this, text, selected, hasFocus, row, column);
VisibleGraph<Integer> visibleGraph = myDataPack.getVisibleGraph();
if (row < 0 || row >= visibleGraph.getVisibleCommitCount()) {
LOG.error("Visible graph has " + visibleGraph.getVisibleCommitCount() + " commits, yet we want row " + row);
return VcsCommitStyleFactory.createStyle(dummyRendererComponent.getForeground(), dummyRendererComponent.getBackground());
}
final RowInfo<Integer> rowInfo = visibleGraph.getRowInfo(row);
VcsLogHighlighter.VcsCommitStyle defaultStyle = VcsCommitStyleFactory
.createStyle(rowInfo.getRowType() == RowType.UNMATCHED ? JBColor.GRAY : dummyRendererComponent.getForeground(),
dummyRendererComponent.getBackground());