diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusAction.java index 529da7371bf7..24ac8fd1c2a3 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/RollbackLineStatusAction.java @@ -44,6 +44,11 @@ public class RollbackLineStatusAction extends DumbAwareAction { e.getPresentation().setEnabledAndVisible(false); return; } + if (!isSomeChangeSelected(editor, tracker)) { + e.getPresentation().setVisible(true); + e.getPresentation().setEnabled(false); + return; + } e.getPresentation().setEnabledAndVisible(true); } @@ -57,6 +62,14 @@ public class RollbackLineStatusAction extends DumbAwareAction { rollback(tracker, editor, null); } + protected static boolean isSomeChangeSelected(@NotNull Editor editor, @NotNull LineStatusTracker tracker) { + List carets = editor.getCaretModel().getAllCarets(); + if (carets.size() != 1) return true; + Caret caret = carets.get(0); + if (caret.hasSelection()) return true; + return tracker.getRangeForLine(caret.getLogicalPosition().line) != null; + } + protected static void rollback(@NotNull LineStatusTracker tracker, @Nullable Editor editor, @Nullable Range range) { assert editor != null || range != null;