private void mergeCandidates(List<Candidate> possible) { // Merge candidates if the have the same key Map<String, List<Candidate>> keyedCandidates = new HashMap<>(); for (Candidate candidate : possible) { if (candidate.key() != null) { List<Candidate> cands = keyedCandidates.computeIfAbsent(candidate.key(), s -> new ArrayList<>()); cands.add(candidate); } } if (!keyedCandidates.isEmpty()) { for (List<Candidate> candidates : keyedCandidates.values()) { if (candidates.size() >= 1) { possible.removeAll(candidates); // Candidates with the same key are supposed to have // the same description candidates.sort(Comparator.comparing(Candidate::value)); Candidate first = candidates.get(0); String disp = candidates.stream() .map(Candidate::displ) .collect(Collectors.joining(" ")); possible.add(new Candidate(first.value(), disp, first.group(), first.descr(), first.suffix(), null, first.complete())); } } } }
if (completion.complete() && getLastBinding().charAt(0) != ' ' && (SELF_INSERT.equals(ref) || getLastBinding().charAt(0) != ' ')) {