import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.fileTypes.FileType;
-import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
return myFile.getFileType().isBinary();
}
- public static FileContent createFromTempFile(Project project, String name, String ext, byte[] content) throws IOException {
+ public static FileContent createFromTempFile(Project project, String name, String ext, @NotNull byte[] content) throws IOException {
final File tempFile = FileUtil.createTempFile(name, ext);
tempFile.deleteOnExit();
FileUtil.writeToFile(tempFile, content);
private void highlighterCreated(RangeHighlighter highlighter, TextAttributes attrs, boolean applied) {
if (attrs != null) {
Color color = attrs.getErrorStripeColor();
- if (applied) {
+ if (color != null && applied) {
color = makeColorForApplied(color);
}
highlighter.setErrorStripeMarkColor(color);
myHighlighters.add(highlighter);
}
- private static Color makeColorForApplied(Color color) {
+ @NotNull
+ private static Color makeColorForApplied(@NotNull Color color) {
return new Color(color.getRed(), color.getGreen(), color.getBlue(), APPLIED_CHANGE_TRANSPARENCY);
}
public void setColorScheme(EditorColorsScheme scheme) {
for (Editor editor : getEditors()) {
- ((EditorEx)editor).setColorsScheme(scheme);
+ if (editor != null) {
+ ((EditorEx)editor).setColorsScheme(scheme);
+ }
}
myPanel.setColorScheme(scheme);
}
fileName,
ArrayUtil.EMPTY_BYTE_ARRAY);
} else {
+ byte[] content = ((BinaryContentRevision)contentRevision).getBinaryContent();
fileContent = FileContent.createFromTempFile(project,
contentRevision.getFile().getName(),
contentRevision.getFile().getName(),
- ((BinaryContentRevision)contentRevision).getBinaryContent());
+ content == null ? ArrayUtil.EMPTY_BYTE_ARRAY : content);
}
return fileContent;
}
return null;
}
final List<Change> changes = record.parseChanges(project, root);
- boolean exists = ! FileStatus.DELETED.equals(changes.get(0).getFileStatus());
+ boolean exists = changes.isEmpty() || !FileStatus.DELETED.equals(changes.get(0).getFileStatus());
record.setUsedHandler(h);
return new ItemLatestState(new GitRevisionNumber(record.getHash(), record.getDate()), exists, false);
}
return 0;
}
+ // One of the revisions is local. Local is "greater" than any from the history.
+ if (changeset.isEmpty()) {
+ return 1;
+ }
+ if (other.changeset.isEmpty()) {
+ return -1;
+ }
+
// compare revision numbers.
final int revCompare = java.lang.Long.valueOf(getRevisionNumber()).compareTo(java.lang.Long.valueOf(other.getRevisionNumber()));
if (revCompare != 0) {