mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-130874 diff: show "Revert dialog" if no line markers selected by caret
This commit is contained in:
@@ -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<Caret> 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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user