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())); } } } }
default: { Candidate completion = menuSupport.completion(); if (completion.suffix() != null) { String chars = getString(REMOVE_SUFFIX_CHARS, DEFAULT_REMOVE_SUFFIX_CHARS); if (SELF_INSERT.equals(ref) && chars.indexOf(getLastBinding().charAt(0)) >= 0 || BACKWARD_DELETE_CHAR.equals(ref)) { buf.backspace(completion.suffix().length()); && completion.suffix() != null && completion.suffix().startsWith(getLastBinding()))) { pushBackBinding(true);