diff --git a/platform/diff-impl/src/com/intellij/diff/DiffContentFactoryImpl.java b/platform/diff-impl/src/com/intellij/diff/DiffContentFactoryImpl.java index 4cfd88f3035f..582a151af741 100644 --- a/platform/diff-impl/src/com/intellij/diff/DiffContentFactoryImpl.java +++ b/platform/diff-impl/src/com/intellij/diff/DiffContentFactoryImpl.java @@ -251,7 +251,7 @@ public class DiffContentFactoryImpl extends DiffContentFactoryEx { @NotNull byte[] content, @NotNull FilePath filePath) throws IOException { if (filePath.getFileType().isBinary()) { - return createBinary(project, content, filePath.getFileType(), filePath.getName()); + return createBinaryImpl(project, content, filePath.getFileType(), filePath.getName(), filePath.getVirtualFile()); } return createDocumentFromBytes(project, content, filePath); @@ -264,7 +264,7 @@ public class DiffContentFactoryImpl extends DiffContentFactoryEx { @NotNull VirtualFile highlightFile) throws IOException { // TODO: check if FileType.UNKNOWN is actually a text ? if (highlightFile.getFileType().isBinary()) { - return createBinary(project, content, highlightFile.getFileType(), highlightFile.getName()); + return createBinaryImpl(project, content, highlightFile.getFileType(), highlightFile.getName(), highlightFile); } return createDocumentFromBytes(project, content, highlightFile); @@ -290,6 +290,15 @@ public class DiffContentFactoryImpl extends DiffContentFactoryEx { @NotNull byte[] content, @NotNull FileType type, @NotNull String fileName) throws IOException { + return createBinaryImpl(project, content, type, fileName, null); + } + + @NotNull + private DiffContent createBinaryImpl(@Nullable Project project, + @NotNull byte[] content, + @NotNull FileType type, + @NotNull String fileName, + @Nullable VirtualFile highlightFile) throws IOException { // workaround - our JarFileSystem and decompilers can't process non-local files boolean useTemporalFile = type instanceof ArchiveFileType || BinaryFileTypeDecompilers.INSTANCE.forFileType(type) != null; @@ -302,7 +311,7 @@ public class DiffContentFactoryImpl extends DiffContentFactoryEx { file.setWritable(false); } - return create(project, file); + return new FileContentImpl(project, file, highlightFile); } @NotNull diff --git a/platform/diff-impl/src/com/intellij/diff/contents/FileContentImpl.java b/platform/diff-impl/src/com/intellij/diff/contents/FileContentImpl.java index e64bff17a297..26a6095871a4 100644 --- a/platform/diff-impl/src/com/intellij/diff/contents/FileContentImpl.java +++ b/platform/diff-impl/src/com/intellij/diff/contents/FileContentImpl.java @@ -32,19 +32,34 @@ public class FileContentImpl extends DiffContentBase implements FileContent { @NotNull private final VirtualFile myFile; @Nullable private final Project myProject; @NotNull private final FileType myType; + @Nullable private final VirtualFile myHighlightFile; public FileContentImpl(@Nullable Project project, @NotNull VirtualFile file) { + this(project, file, getHighlightFile(file)); + } + + public FileContentImpl(@Nullable Project project, + @NotNull VirtualFile file, + @Nullable VirtualFile highlightFile) { assert file.isValid() && !file.isDirectory(); - myProject = project; myFile = file; + myProject = project; myType = file.getFileType(); + myHighlightFile = highlightFile; } @Nullable @Override public Navigatable getNavigatable() { - if (myProject == null || myProject.isDefault() || !myFile.isValid()) return null; - return new OpenFileDescriptor(myProject, myFile); + if (myProject == null || myProject.isDefault()) return null; + if (myHighlightFile == null || !myHighlightFile.isValid()) return null; + return new OpenFileDescriptor(myProject, myHighlightFile); + } + + @Nullable + private static VirtualFile getHighlightFile(@NotNull VirtualFile file) { + if (file.isInLocalFileSystem()) return file; + return null; } @NotNull diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/ChangeDiffRequestProducer.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/ChangeDiffRequestProducer.java index d4fe1491df80..74ff182f3e92 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/ChangeDiffRequestProducer.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/ChangeDiffRequestProducer.java @@ -226,9 +226,9 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer { @NotNull private DiffRequest createRequest(@Nullable Project project, - @NotNull Change change, - @NotNull UserDataHolder context, - @NotNull ProgressIndicator indicator) throws DiffRequestProducerException { + @NotNull Change change, + @NotNull UserDataHolder context, + @NotNull ProgressIndicator indicator) throws DiffRequestProducerException { if (ChangesUtil.isTextConflictingChange(change)) { // three side diff // FIXME: This part is ugly as a VCS merge subsystem itself. @@ -388,7 +388,7 @@ public class ChangeDiffRequestProducer implements DiffRequestProducer { if (content == null) { throw new DiffRequestProducerException("Can't get binary revision content"); } - return contentFactory.createBinary(project, content, filePath.getFileType(), filePath.getName()); + return contentFactory.createFromBytes(project, content, filePath); } if (revision instanceof ByteBackedContentRevision) {