Commit fff77c7
authored
✨ unsort the completions in
### motivation
Hi! This is something I wanted since [#14424 of
nushell/nushell](nushell/nushell#14424) landed.
Unsorted completions on the `git checkout` command
### The 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:
```
git checkout <tab>
```
before: (these are sorted)

after: (these aren't)

### How?
Citing the docs:
https://www.nushell.sh/book/custom_completions.html#options-for-custom-completions
```
{
options: {
case_sensitive: false,
completion_algorithm: prefix,
positional: false,
sort: false,
},
completions: [cat, rat, bat]
}
}
```
and I passed **a table** to the `completions` key, instead of a _list_.
```
completions: $table_of_checkouts
```git checkout (#1022)1 parent e245718 commit fff77c7
1 file changed
+11
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
| |||
125 | 133 | | |
126 | 134 | | |
127 | 135 | | |
128 | | - | |
| 136 | + | |
129 | 137 | | |
130 | 138 | | |
131 | 139 | | |
| |||
0 commit comments