IDEA-195309 Support Ctrl+Backspace in SpeedSearch

This commit is contained in:
Vassiliy.Kudryashov
2018-07-20 11:39:13 +03:00
parent 718499fe79
commit 0a6fb7dcb4
2 changed files with 17 additions and 1 deletions
@@ -231,6 +231,13 @@ public class KeymapUtil {
return shortcut == null? "" : getShortcutText(shortcut);
}
public static boolean isEventForAction(@NotNull KeyEvent keyEvent, @NotNull String actionId) {
for (KeyboardShortcut shortcut : ContainerUtil.findAll(getActiveKeymapShortcuts(actionId).getShortcuts(), KeyboardShortcut.class)) {
if (AWTKeyStroke.getAWTKeyStrokeForEvent(keyEvent) == shortcut.getFirstKeyStroke()) return true;
}
return false;
}
@NotNull
public static String getFirstKeyboardShortcutText(@NotNull AnAction action) {
return getFirstKeyboardShortcutText(action.getShortcutSet());
@@ -15,6 +15,7 @@
*/
package com.intellij.ui.speedSearch;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.codeStyle.AllOccurrencesMatcher;
import com.intellij.psi.codeStyle.FixingLayoutMatcher;
@@ -68,7 +69,15 @@ public class SpeedSearch extends SpeedSearchSupply implements KeyListener {
String old = myString;
if (e.getID() == KeyEvent.KEY_PRESSED) {
if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
if (KeymapUtil.isEventForAction(e, "EditorDeleteToWordStart")) {
if (isHoldingFilter()) {
while (!myString.isEmpty() && !Character.isWhitespace(myString.charAt(myString.length() - 1))) {
backspace();
}
e.consume();
}
}
else if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
backspace();
e.consume();
}