diff --git a/python/src/com/jetbrains/python/codeInsight/imports/ImportFromExistingAction.java b/python/src/com/jetbrains/python/codeInsight/imports/ImportFromExistingAction.java index 2a70fd643bb9..86c97a11eb67 100644 --- a/python/src/com/jetbrains/python/codeInsight/imports/ImportFromExistingAction.java +++ b/python/src/com/jetbrains/python/codeInsight/imports/ImportFromExistingAction.java @@ -109,10 +109,12 @@ public class ImportFromExistingAction implements QuestionAction { final Runnable runnable = new Runnable() { public void run() { - int index = list.getSelectedIndex(); - if (index < 0) return; - PsiDocumentManager.getInstance(myTarget.getProject()).commitAllDocuments(); - doWriteAction(mySources.get(index)); + final Object selected = list.getSelectedValue(); + if (selected instanceof ImportCandidateHolder) { + final ImportCandidateHolder item = (ImportCandidateHolder)selected; + PsiDocumentManager.getInstance(myTarget.getProject()).commitAllDocuments(); + doWriteAction(item); + } } };