mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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()`)
This commit is contained in:
committed by
Aleksey Pivovarov
parent
89c6a1b5b5
commit
29fbf91247
+2
-1
@@ -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
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user