From e388646cc80651b2dfa23604ab93e78dcf5f4fa5 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Sun, 7 Sep 2014 12:47:29 +0400 Subject: [PATCH] fix once and forever accidental deleting by backspace while editing speed search pattern --- .../keymap/impl/IdeKeyEventDispatcher.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java index 9a566e9915ef..72e24d626535 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java @@ -55,6 +55,7 @@ import com.intellij.ui.ComponentWithMnemonics; import com.intellij.ui.SimpleTextAttributes; import com.intellij.ui.components.JBOptionButton; import com.intellij.ui.popup.list.ListPopupImpl; +import com.intellij.ui.speedSearch.SpeedSearchSupply; import com.intellij.util.Alarm; import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; @@ -140,6 +141,10 @@ public final class IdeKeyEventDispatcher implements Disposable { return false; } + if (isSpeedSearchEditing(e)) { + return false; + } + // http://www.jetbrains.net/jira/browse/IDEADEV-12372 if (e.getKeyCode() == KeyEvent.VK_CONTROL) { if (e.getID() == KeyEvent.KEY_PRESSED) { @@ -226,6 +231,18 @@ public final class IdeKeyEventDispatcher implements Disposable { } } + private static boolean isSpeedSearchEditing(KeyEvent e) { + int keyCode = e.getKeyCode(); + if (keyCode == KeyEvent.VK_BACK_SPACE) { + Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); + if (owner instanceof JComponent) { + SpeedSearchSupply supply = SpeedSearchSupply.getSupply((JComponent)owner); + return supply != null && supply.isPopupActive(); + } + } + return false; + } + /** * @return true if and only if the component represents * modal context.