IDEA-64883 Don't save document if it is null (file type is unknown)
authorKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Thu, 5 May 2011 11:48:56 +0000 (15:48 +0400)
committerKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Thu, 5 May 2011 11:54:20 +0000 (15:54 +0400)
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/CompareWithSelectedRevisionAction.java

index 9f58452be6bcca9fe73b85d7e1e3371b63ac8937..9693592686ad6c72fa6fa94041f161895b69afa5 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.openapi.vcs.actions;
 
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.Presentation;
+import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.fileEditor.FileDocumentManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.popup.JBPopup;
@@ -113,7 +114,11 @@ public class CompareWithSelectedRevisionAction extends AbstractVcsAction {
   protected void actionPerformed(VcsContext vcsContext) {
     final VirtualFile file = vcsContext.getSelectedFiles()[0];
     final FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
-    fileDocumentManager.saveDocument(fileDocumentManager.getDocument(file));
+    final Document document = fileDocumentManager.getDocument(file);
+    if (document != null) {
+      fileDocumentManager.saveDocument(document);
+    }
+
     final Project project = vcsContext.getProject();
     final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
     final VcsHistoryProvider vcsHistoryProvider = vcs.getVcsHistoryProvider();