IDEA-165089 reset keymap actions to parent, not to original values

This commit is contained in:
Sergey Malenkov
2017-04-28 19:49:54 +03:00
parent a66b699561
commit 8f8a1f6fb0
2 changed files with 8 additions and 11 deletions
@@ -54,7 +54,7 @@ final class KeymapScheme implements Scheme {
}
@NotNull
Keymap getCurrent() {
KeymapImpl getCurrent() {
return mutable != null ? mutable : original;
}
@@ -83,26 +83,21 @@ final class KeymapScheme implements Scheme {
}
boolean canReset() {
return mutable != null && !mutable.equals(original);
return getCurrent().getOwnActionIds().length > 0;
}
void reset() {
assert canReset() : "reset all modified shortcuts unexpectedly";
mutable = null;
getMutable().clearOwnActionsIds();
}
boolean canReset(@NotNull String actionId) {
return mutable != null && !deepEquals(original.getShortcuts(actionId), mutable.getShortcuts(actionId));
return getCurrent().hasOwnActionId(actionId);
}
void reset(@NotNull String actionId) {
assert canReset(actionId) : "reset modified action shortcuts unexpectedly";
if (mutable != null) {
mutable.removeAllActionShortcuts(actionId);
for (Shortcut shortcut : original.getShortcuts(actionId)) {
mutable.addShortcut(actionId, shortcut);
}
}
getMutable().clearOwnActionsId(actionId);
}
@NotNull
@@ -104,7 +104,9 @@ final class KeymapSelector extends SimpleSchemesPanel<KeymapScheme> implements S
void resetActionInKeymap(Keymap mutable, String actionId) {
KeymapScheme scheme = find(mutable);
if (scheme != null) scheme.reset(actionId);
if (scheme == null) return;
scheme.reset(actionId);
selectKeymap(scheme, false);
}
private KeymapScheme find(Keymap keymap) {