feat: Patch sorting popup autocomplete items and initial builtin items #2518
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I noticed that neovim wasn't sorting the list of autocomplete items when pressing tab in the command line.
In my very limited lua + nvim knowledge, there doesn't seem to be a way to create an autocommand that intercepts the completion list in the command popup.
So I decided to try my hand at brute-forcing the solution from telescope's side.
Here I sort the list of available commands for each of the 4 possible code paths.
The initial builtin list is also unsorted.
Let me know if this is useful or if you have any other recommendations for sorting the options. It's also ok if this feature is not wanted. 👍
(I messed up and renamed the branch on the closed PR #2515 not knowing GH would close it. Sorry for the double submission)
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list relevant details about your configuration
Various
print
commands to ensure I hit all 4 paths.Testing the autocompletions manually and ensuring no errors or unexpected suggestions.
n == 0
:Telescope <Tab>
:Telescope l<Tab>
n == 1 and #is_extension > 0
:Telescope gh <Tab>
n == 1 and #is_extension == 0
:Telescope autocommands <Tab>
n > 1
:Telescope autocommands wrap_results <Tab>
:Telescope gh issues <Tab>
Builtin list
Left: Before
Right: After
All tests pass on the fork ✅
Configuration:
Checklist: