IDEA-187479 diff: do not show active diff tool in "Diff Settings Popup"

Active tool might be a substituted one, so we should not show its "base" tool.
This commit is contained in:
Aleksey Pivovarov
2018-03-14 14:40:31 +03:00
parent 6d3fb3734d
commit c9b6e56e06
@@ -198,8 +198,8 @@ public abstract class DiffRequestProcessor implements Disposable {
FrameDiffTool tool = tools.isEmpty() ? ErrorDiffTool.INSTANCE : tools.get(0);
if (applySubstitutor) {
DiffTool substitutor = DiffUtil.findToolSubstitutor(tool, myContext, myActiveRequest);
if (substitutor instanceof FrameDiffTool) return (FrameDiffTool)substitutor;
FrameDiffTool substitutor = findToolSubstitutor(tool);
if (substitutor != null) return substitutor;
}
return tool;
@@ -220,8 +220,8 @@ public abstract class DiffRequestProcessor implements Disposable {
result.add((FrameDiffTool)tool);
}
else {
DiffTool substitutor = DiffUtil.findToolSubstitutor(tool, myContext, myActiveRequest);
if (substitutor instanceof FrameDiffTool) {
FrameDiffTool substitutor = findToolSubstitutor(tool);
if (substitutor != null) {
result.add((FrameDiffTool)tool);
}
}
@@ -235,6 +235,11 @@ public abstract class DiffRequestProcessor implements Disposable {
return DiffUtil.filterSuppressedTools(result);
}
private FrameDiffTool findToolSubstitutor(@NotNull DiffTool tool) {
DiffTool substitutor = DiffUtil.findToolSubstitutor(tool, myContext, myActiveRequest);
return substitutor instanceof FrameDiffTool ? (FrameDiffTool)substitutor : null;
}
private void moveToolOnTop(@NotNull DiffTool tool) {
myToolOrder.remove(tool);
@@ -448,7 +453,8 @@ public abstract class DiffRequestProcessor implements Disposable {
List<AnAction> selectToolActions = new ArrayList<>();
for (DiffTool tool : getAvailableFittedTools()) {
if (tool == myState.getActiveTool()) continue;
FrameDiffTool substitutor = findToolSubstitutor(tool);
if (tool == myState.getActiveTool() || substitutor == myState.getActiveTool()) continue;
selectToolActions.add(new DiffToolToggleAction(tool));
}
DiffUtil.addActionBlock(myPopupActionGroup, selectToolActions);