Skip to content

Commit

Permalink
Merge pull request #2187 from Haehnchen/feature/form-theme-prio
Browse files Browse the repository at this point in the history
add priority voting for Twig form_theme completion
  • Loading branch information
Haehnchen authored Jun 25, 2023
2 parents dbfb974 + 393cb57 commit eebad71
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,18 @@ protected void addCompletions(@NotNull CompletionParameters parameters, @NotNull
return;
}

resultSet.addAllElements(TwigUtil.getTwigLookupElements(parameters.getPosition().getProject()));
Project project = parameters.getPosition().getProject();
List<String> prioritizedKeys = TwigUtil.getFormThemeTemplateUsageAsOrderedList(project);

if (prioritizedKeys.size() > 0) {
CompletionSorter completionSorter = CompletionService.getCompletionService()
.defaultSorter(parameters, resultSet.getPrefixMatcher())
.weighBefore("priority", new ServiceCompletionProvider.MyLookupElementWeigher(prioritizedKeys));

resultSet = resultSet.withRelevanceSorter(completionSorter);
}

resultSet.addAllElements(TwigUtil.getTwigLookupElements(project, new HashSet<>(prioritizedKeys)));
}
}

Expand Down

0 comments on commit eebad71

Please sign in to comment.