Skip to content

Commit

Permalink
[feature] better ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
marmoure committed Nov 14, 2023
1 parent 0db8069 commit 5c54d09
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

import java.awt.*;
import java.util.List;
import java.util.stream.Collectors;

/**
* TEI-Completer
Expand Down Expand Up @@ -90,12 +91,19 @@ public String getDescription() {
public List<CIValue> filterAttributeValues(final List<CIValue> list, final WhatPossibleValuesHasAttributeContext context) {
if (context != null) {
final AutoCompleteSuggestions<AutoComplete> autoCompleteSuggestions = getAutoCompleteSuggestions(context);

if(autoCompleteSuggestions != null) {
list.addAll(autoCompleteSuggestions.getSuggestions());
List<CIValue> spacePrefixedList = autoCompleteSuggestions.getSuggestions().stream().map(ciValue -> {
ciValue.setValue(" " + ciValue.getValue());
return ciValue;
}).collect(Collectors.toList());

list.addAll(spacePrefixedList);
}

if(autoCompleteSuggestions != null) {
// the value needs to be prefixed with a space character to bump it to the top of the list
list.add(new CustomCIValue(" Custom lookup...", this, autoCompleteSuggestions.autoCompleteContext));
list.add(new CustomCIValue("\uD83D\uDC49 Custom lookup...", this, autoCompleteSuggestions.autoCompleteContext));
}

}
Expand Down

0 comments on commit 5c54d09

Please sign in to comment.