IDEA-132332 Open Task Hangs if submitted too quickly

This commit is contained in:
Dmitry Avdeev
2014-11-06 18:48:25 +03:00
parent 83bf1e448b
commit 683301ebaf
3 changed files with 19 additions and 4 deletions
@@ -1192,6 +1192,10 @@ public abstract class ChooseByNameBase {
myPostponedOkAction = null;
}
public boolean hasPostponedAction() {
return myPostponedOkAction != null;
}
protected abstract void showList();
protected abstract void hideList();
@@ -54,7 +54,6 @@ public class GotoTaskAction extends GotoActionBase implements DumbAware {
popup.setShowListForEmptyPattern(true);
popup.setSearchInAnyPlace(true);
popup.setFixLostTyping(false);
popup.setAlwaysHasMore(true);
popup.setAdText("<html>Press SHIFT to merge with current context<br/>" +
"Pressing " +
@@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicReference;
class TaskItemProvider implements ChooseByNameItemProvider, Disposable {
private static final Logger LOG = Logger.getInstance(TaskItemProvider.class);
private static final int DELAY_PERIOD = 1000; // ms
private static final int DELAY_PERIOD = 200; // ms
private final Project myProject;
@@ -85,10 +85,22 @@ class TaskItemProvider implements ChooseByNameItemProvider, Disposable {
if (myAlarm.isDisposed()) {
return false;
}
myAlarm.addRequest(future, DELAY_PERIOD);
myAlarm.addRequest(future, oldFuture == null && pattern.length() > 5 ? 0 : DELAY_PERIOD);
try {
List<Task> tasks = future.get();
List<Task> tasks;
while (true) {
try {
tasks = future.get(10, TimeUnit.MILLISECONDS);
break;
}
catch (TimeoutException ignore) {
}
if (base.hasPostponedAction()) {
future.cancel(true);
return true;
}
}
myFutureReference.compareAndSet(future, null);
// Exclude *all* cached and local issues, not only those returned by TaskSearchSupport.getLocalAndCachedTasks().