don't show disabled actions in go to action

use the registry option goto.action.skip.disabled if you don't like it
fixes IDEA-127307
This commit is contained in:
Sergey Ignatov
2017-06-22 01:47:13 +03:00
parent dd30a966cc
commit fdf4ac9b80
3 changed files with 22 additions and 3 deletions
@@ -183,7 +183,7 @@ public class GotoActionAction extends GotoActionBase implements DumbAware {
@NotNull
@Override
protected Set<Object> filter(@NotNull Set<Object> elements) {
return super.filter(model.sortItems(elements));
return super.filter(model.filterAndSortItems(elements));
}
@Override
@@ -35,6 +35,7 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.MinusculeMatcher;
@@ -406,14 +407,29 @@ public class GotoActionModel implements ChooseByNameModel, Comparator<Object>, D
}
@NotNull
public SortedSet<Object> sortItems(@NotNull Set<Object> elements) {
public SortedSet<Object> filterAndSortItems(@NotNull Set<Object> elements) {
List<ActionWrapper> toUpdate = getActionsToUpdate(elements);
if (!toUpdate.isEmpty()) {
updateActions(toUpdate);
}
TreeSet<Object> objects = ContainerUtilRt.newTreeSet(this);
objects.addAll(elements);
if (Registry.is("goto.action.skip.disabled")) {
for (Object o : elements) {
if (o instanceof MatchedValue) {
Comparable v = ((MatchedValue)o).value;
if (!(v instanceof ActionWrapper) || ((ActionWrapper)v).isAvailable()) {
objects.add(o);
}
}
else {
objects.add(o);
}
}
}
else {
objects.addAll(elements);
}
return objects;
}
@@ -1169,5 +1169,8 @@ ESLint.Language.Service.full.log.description=ESLint: include source code fragmen
goto.action.skip.tophits.and.options=false
goto.action.skip.tophits.and.options.description=Skip top hits and options in go to action
goto.action.skip.disabled=true
goto.action.skip.disabled.description=Show only enabled actions in Go to Action
dsm.show.cycle.count.in.tooltip=false
dsm.show.cycle.count.in.tooltip.description=Shows number of cycles found in the tooltip of the Toggle Cycles toolbar button after some calculation time