-
Bug
-
Resolution: Done
-
Major
-
1.8
-
None
-
None
I am using a custom Completion<CompleteOperation> implementation, which provides a list of valid completions for my use case.
The completion list is populated like this:
possibleCompletions = Files.list(currentPath).filter(isOnlyDirectories ? isDirectory() : path -> true) .filter(isHiddenFile(incompleteFilename).negate()) .filter(startsWithIncompleteFilename(incompleteFilename)) .map(Path::getFileName) .map(Path::toString) .map(filename -> Files.isDirectory(currentPath.resolve(filename)) ? filename + File.separator : filename) .sorted(Comparator.comparing(String::toLowerCase)) .collect(Collectors.toList());
which results in the results and ordering I want. However, this code:
CompletionHandler.java Line 209-220:
private void displayCompletions(List<TerminalString> completions, Buffer buffer, InputProcessor inputProcessor) { Collections.sort(completions); inputProcessor.buffer().writeOut(Config.CR); inputProcessor.buffer().writeOut(Parser.formatDisplayListTerminalString(completions, inputProcessor.buffer().size().getHeight(), inputProcessor.buffer().size().getWidth())); buffer.setIsPromptDisplayed(false); buffer.invalidateCursorLocation(); inputProcessor.buffer().drawLine(); }
calls
Collections.sort(completions);
which re-sorts my provided list and changes the order completions are listed in.
I debated putting this under a bug or a feature-request / enhancement, sorry if I've put it into the wrong category
It would be nice to either
- have the code assume that completions are being provided in a sorted order that is appropriate for the given completion
- provide a way to disable the sorting that occurs in the displayCompletions() method
I'd be willing to help with a PR on this too!
- causes
-
JBEAP-14919 Pathcompletation offers candidates sorted in case-sensitive order
- Closed