✨ unsort the completions in git checkout
#1022
Merged
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.
motivation
Hi! This is something I wanted since #14424 of nushell/nushell landed.
Unsorted completions on the
git checkout
commandThe problem
is that git checkout accepts lots of things: commits hashes, filenames, local branches and remote branches. Since the mentioned pr all the completions were sorted, but for this command it didn't make sense.
I used
git switch
to checkout a branch for the time being, but it's a little annoying that you can't push "unsorted" completions on a command.the result
With the help of ysthakur and weirdan, I managed to achieve this:
before: (these are sorted)
![image](https://private-user-images.githubusercontent.com/30557287/406790380-ad495b29-e418-426f-9bbe-2056f34b819f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMDU4NTksIm5iZiI6MTczOTAwNTU1OSwicGF0aCI6Ii8zMDU1NzI4Ny80MDY3OTAzODAtYWQ0OTViMjktZTQxOC00MjZmLTliYmUtMjA1NmYzNGI4MTlmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDA5MDU1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZjYzk0ZTY2OWM0MmUyY2FiNzRjMDUyODg5Njg5NjhiN2FkNDE0MGEyNTdmN2EyNzQyM2YwOTI1MWMwOGY1MmImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.b-f3AqIpf-Pk90lsJRqtV4iFzYmJcyAGJNE7zkktkyw)
after: (these aren't)
![image](https://private-user-images.githubusercontent.com/30557287/406790259-e2b5d647-cccb-4e0b-b1c2-b80781ada3ec.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMDU4NTksIm5iZiI6MTczOTAwNTU1OSwicGF0aCI6Ii8zMDU1NzI4Ny80MDY3OTAyNTktZTJiNWQ2NDctY2NjYi00ZTBiLWIxYzItYjgwNzgxYWRhM2VjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDA5MDU1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ3NmMxMzUyZDVjNjEyZTJkYTA4M2EzZjEwMDhjZTYxOGZhNGRiODk2MGVjNGQ2NWQxNGVhODE0YmMyZWZlZmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.QgODEkWeRlcSFQMJZG8qjwtMWPqjfAn2DonwrMfR4G8)
How?
Citing the docs:
https://www.nushell.sh/book/custom_completions.html#options-for-custom-completions
and I passed a table to the
completions
key, instead of a list.