fix NPE if MultipleFileMergeDialog was created without project (as ICS does)

This commit is contained in:
Vladimir Krivosheev
2015-08-25 13:51:40 +02:00
parent c12f1a627b
commit 07e19a683b
2 changed files with 9 additions and 3 deletions
@@ -701,13 +701,18 @@ public class TextMergeTool implements MergeTool {
}
private void registerUndoRedo(final boolean undo) {
Project project = getProject();
if (project == null) {
return;
}
List<TextMergeChange> affectedChanges = getAffectedChanges();
final List<TextMergeChange.State> states = new ArrayList<TextMergeChange.State>(affectedChanges.size());
for (TextMergeChange change : affectedChanges) {
states.add(change.storeState());
}
UndoManager.getInstance(getProject()).undoableActionPerformed(new BasicUndoableAction(myDocument) {
UndoManager.getInstance(project).undoableActionPerformed(new BasicUndoableAction(myDocument) {
@Override
public void undo() throws UnexpectedUndoException {
if (undo) restoreStates(states);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,12 +21,13 @@ import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class UndoManager {
public static final Key<Document> ORIGINAL_DOCUMENT = new Key<Document>("ORIGINAL_DOCUMENT");
public static UndoManager getInstance(Project project) {
public static UndoManager getInstance(@NotNull Project project) {
return project.getComponent(UndoManager.class);
}