mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
speed-search: KEY_TYPED events only (non-ISO shortcuts): backspace fix
This commit is contained in:
@@ -21,6 +21,7 @@ import com.intellij.psi.codeStyle.FixingLayoutMatcher;
|
||||
import com.intellij.psi.codeStyle.MinusculeMatcher;
|
||||
import com.intellij.psi.codeStyle.NameUtil;
|
||||
import com.intellij.util.text.Matcher;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -62,21 +63,24 @@ public class SpeedSearch extends SpeedSearchSupply implements KeyListener {
|
||||
myString.length() == 0 || (myMatcher != null && myMatcher.matches(string));
|
||||
}
|
||||
|
||||
public void process(KeyEvent e) {
|
||||
public void processKeyEvent(KeyEvent e) {
|
||||
if (e.isConsumed()) return;
|
||||
|
||||
String old = myString;
|
||||
if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
|
||||
backspace();
|
||||
e.consume();
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
||||
if (isHoldingFilter()) {
|
||||
updatePattern("");
|
||||
if (e.getID() == KeyEvent.KEY_PRESSED) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
|
||||
backspace();
|
||||
e.consume();
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
|
||||
if (isHoldingFilter()) {
|
||||
updatePattern("");
|
||||
e.consume();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.getID() == KeyEvent.KEY_TYPED) {
|
||||
if (!UIUtil.isReallyTypedEvent(e)) return;
|
||||
// key-char is good only on KEY_TYPED
|
||||
// for example: key-char on ctrl-J PRESSED is \n
|
||||
// see https://en.wikipedia.org/wiki/Control_character
|
||||
@@ -187,16 +191,16 @@ public class SpeedSearch extends SpeedSearchSupply implements KeyListener {
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
process(e);
|
||||
processKeyEvent(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
process(e);
|
||||
processKeyEvent(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
process(e);
|
||||
processKeyEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,8 +367,8 @@ public abstract class WizardPopup extends AbstractPopup implements ActionListene
|
||||
return proceedKeyEvent(event, stroke);
|
||||
}
|
||||
|
||||
myMnemonicsSearch.process(event);
|
||||
mySpeedSearch.process(event);
|
||||
myMnemonicsSearch.processKeyEvent(event);
|
||||
mySpeedSearch.processKeyEvent(event);
|
||||
|
||||
if (event.isConsumed()) return true;
|
||||
process(event);
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.ui.popup.util;
|
||||
import com.intellij.openapi.ui.popup.MnemonicNavigationFilter;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.popup.WizardPopup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.HashMap;
|
||||
@@ -46,7 +47,7 @@ public abstract class MnemonicsSearch<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public void process(KeyEvent e) {
|
||||
public void processKeyEvent(@NotNull KeyEvent e) {
|
||||
if (e.isConsumed()) return;
|
||||
if (e.getID() != KeyEvent.KEY_TYPED) return;
|
||||
if (!StringUtil.isEmptyOrSpaces(myPopup.getSpeedSearch().getFilter())) return;
|
||||
|
||||
Reference in New Issue
Block a user