diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/GoToHashOrRefPopup.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/GoToHashOrRefPopup.java index 29b3f54a39d4..b085efb224c5 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/GoToHashOrRefPopup.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/GoToHashOrRefPopup.java @@ -63,44 +63,46 @@ public class GoToHashOrRefPopup { @Nullable private VcsRef mySelectedRef; public GoToHashOrRefPopup(@NotNull final Project project, - @NotNull Collection variants, Collection roots, + @NotNull Collection variants, + Collection roots, @NotNull Function onSelectedHash, @NotNull Function onSelectedRef, @NotNull VcsLogColorManager colorManager, @NotNull Comparator comparator) { myOnSelectedHash = onSelectedHash; myOnSelectedRef = onSelectedRef; - myTextField = new TextFieldWithProgress(project, new VcsRefCompletionProvider(project, variants, roots, colorManager, comparator)) { - @Override - public void onOk() { - if (myFuture == null) { - final Future future = ((mySelectedRef == null || (!mySelectedRef.getName().equals(getText().trim()))) - ? myOnSelectedHash.fun(getText().trim()) - : myOnSelectedRef.fun(mySelectedRef)); - myFuture = future; - showProgress(); - ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { - @Override - public void run() { - try { - future.get(); - okPopup(); + myTextField = + new TextFieldWithProgress(project, new VcsRefCompletionProvider(project, variants, roots, colorManager, comparator)) { + @Override + public void onOk() { + if (myFuture == null) { + final Future future = ((mySelectedRef == null || (!mySelectedRef.getName().equals(getText().trim()))) + ? myOnSelectedHash.fun(getText().trim()) + : myOnSelectedRef.fun(mySelectedRef)); + myFuture = future; + showProgress(); + ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { + @Override + public void run() { + try { + future.get(); + okPopup(); + } + catch (CancellationException ex) { + cancelPopup(); + } + catch (InterruptedException ex) { + cancelPopup(); + } + catch (ExecutionException ex) { + LOG.error(ex); + cancelPopup(); + } } - catch (CancellationException ex) { - cancelPopup(); - } - catch (InterruptedException ex) { - cancelPopup(); - } - catch (ExecutionException ex) { - LOG.error(ex); - cancelPopup(); - } - } - }); + }); + } } - } - }; + }; myTextField.setAlignmentX(Component.LEFT_ALIGNMENT); JBLabel label = new JBLabel("Enter hash or branch/tag name:"); @@ -226,7 +228,19 @@ public class GoToHashOrRefPopup { @Override public void handleInsert(InsertionContext context, LookupElement item) { mySelectedRef = (VcsRef)item.getObject(); - myTextField.onOk(); + ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override + public void run() { + // handleInsert is called in the middle of some other code that works with editor + // (see CodeCompletionHandlerBase.insertItem) + // for example, scrolls editor + // problem is that in onOk we make text field not editable + // by some reason this is done by disposing its editor and creating a new one + // so editor gets disposed here and CodeCompletionHandlerBase can not finish doing whatever it is doing with it + // I counter this by invoking onOk in invokeLater + myTextField.onOk(); + } + }); } }; }