mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-190270 After clearing search, the cursor jump back
This commit is contained in:
@@ -30,6 +30,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.components.labels.LinkLabel;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.update.Activatable;
|
||||
import com.intellij.util.ui.update.UiNotifyConnector;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -426,7 +427,8 @@ public class EditorSearchSession implements SearchSession,
|
||||
if (mySearchResults != null) {
|
||||
mySearchResults.clear();
|
||||
}
|
||||
if (allowedToChangedEditorSelection) {
|
||||
if (allowedToChangedEditorSelection
|
||||
&& !UIUtil.isClientPropertyTrue(myComponent.getSearchTextComponent(), SearchTextArea.JUST_CLEARED_KEY)) {
|
||||
restoreInitialCaretPositionAndSelection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ import static java.awt.event.InputEvent.*;
|
||||
import static javax.swing.ScrollPaneConstants.*;
|
||||
|
||||
public class SearchTextArea extends NonOpaquePanel implements PropertyChangeListener, FocusListener {
|
||||
public static final String JUST_CLEARED_KEY = "JUST_CLEARED";
|
||||
public static final KeyStroke NEW_LINE_KEYSTROKE
|
||||
= KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, (SystemInfo.isMac ? META_DOWN_MASK : CTRL_DOWN_MASK) | SHIFT_DOWN_MASK);
|
||||
private final JTextArea myTextArea;
|
||||
@@ -128,6 +129,9 @@ public class SearchTextArea extends NonOpaquePanel implements PropertyChangeList
|
||||
myTextArea.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(DocumentEvent e) {
|
||||
if (e.getType() == DocumentEvent.EventType.INSERT) {
|
||||
myTextArea.putClientProperty(JUST_CLEARED_KEY, null);
|
||||
}
|
||||
updateIconsLayout();
|
||||
}
|
||||
});
|
||||
@@ -415,6 +419,7 @@ public class SearchTextArea extends NonOpaquePanel implements PropertyChangeList
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
myTextArea.putClientProperty(JUST_CLEARED_KEY, !myTextArea.getText().isEmpty());
|
||||
myTextArea.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user