From 3c97345d7007b163c11045a3a7d9399abccc86c7 Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Fri, 14 Nov 2014 17:29:46 +0300 Subject: [PATCH] Fixed selecting the corret item from an import suggestions list after filtering (PY-11697) --- .../codeInsight/imports/ImportFromExistingAction.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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); + } } };