diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java index c1b9c98767c1..c88deb758f6e 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNameBase.java @@ -78,6 +78,7 @@ public abstract class ChooseByNameBase{ protected final Project myProject; protected final ChooseByNameModel myModel; protected final String myInitialText; + private boolean myPreselectInitialText; private final Reference myContext; protected Component myPreviouslyFocusedComponent; @@ -147,6 +148,14 @@ public abstract class ChooseByNameBase{ myContext = new WeakReference(context); } + public boolean isPreselectInitialText() { + return myPreselectInitialText; + } + + public void setPreselectInitialText(boolean preselectInitialText) { + myPreselectInitialText = preselectInitialText; + } + /** * Set tool area. The method may be called only before invoke. * @param toolArea a tool area component @@ -321,6 +330,9 @@ public abstract class ChooseByNameBase{ myFuture = new ArrayList>(); myTextField = new MyTextField(); myTextField.setText(myInitialText); + if (myPreselectInitialText) { + myTextField.select(0, myInitialText.length()); + } final ActionMap actionMap = new ActionMap(); actionMap.setParent(myTextField.getActionMap()); diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java index 7549872216e8..7058a7aae294 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/ChooseByNamePopup.java @@ -40,6 +40,9 @@ public class ChooseByNamePopup extends ChooseByNameBase implements ChooseByNameP private ChooseByNamePopup(final Project project, final ChooseByNameModel model, final ChooseByNamePopup oldPopup, final PsiElement context, @Nullable final String predefinedText) { super(project, model, oldPopup != null ? oldPopup.getEnteredText() : predefinedText, context); + if (oldPopup == null && predefinedText != null) { + setPreselectInitialText(true); + } if (oldPopup != null) { //inherit old focus owner myOldFocusOwner = oldPopup.myPreviouslyFocusedComponent; }