Commit 29fbf912 authored by Aleksey Pivovarov's avatar Aleksey Pivovarov Committed by Aleksey Pivovarov
Browse files

IDEA-128057 editor: consume shortcut for "next occurence" action even if there are nothing found

These are local actions and we don't want their shortcuts to trigger some other action while search field is in focus (even if they have nothing to do).
We still want `update()` to mark actions as disabled on toolbar.

Issue:
* open "Commit Changes" dialog
* type "some commit message in a commit message editor"
* invoke search
* search for "comm", iterate over occurrences using "Enter"
* search for "comment", try to iterate over occurrences using "Enter"
* Bug: Dialog is closed, changes are committed (action is disabled and "Enter" is passed to the outer dialog, invoking `doOkAction()`)
parent 89c6a1b5
Branches unavailable Tags unavailable
No related merge requests found
Showing with 6 additions and 3 deletions
+6 -3
......@@ -36,7 +36,8 @@ public final class NextOccurrenceAction extends PrevNextOccurrenceAction {
@Override
public void actionPerformed(AnActionEvent e) {
e.getRequiredData(SearchSession.KEY).searchForward();
SearchSession session = e.getRequiredData(SearchSession.KEY);
if (session.hasMatches()) session.searchForward();
}
@NotNull
......
......@@ -35,7 +35,8 @@ public abstract class PrevNextOccurrenceAction extends DumbAwareAction implement
@Override
public final void update(AnActionEvent e) {
SearchSession search = e.getData(SearchSession.KEY);
e.getPresentation().setEnabled(search != null && search.hasMatches());
boolean invokedByShortcut = !ActionPlaces.isToolbarPlace(e.getPlace());
e.getPresentation().setEnabled(search != null && (invokedByShortcut || search.hasMatches()));
}
@Nullable
......
......@@ -39,7 +39,8 @@ public final class PrevOccurrenceAction extends PrevNextOccurrenceAction {
@Override
public void actionPerformed(AnActionEvent e) {
e.getRequiredData(SearchSession.KEY).searchBackward();
SearchSession session = e.getRequiredData(SearchSession.KEY);
if (session.hasMatches()) session.searchBackward();
}
@NotNull
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment