Skip to content

Commit 60a5efd

Browse files
authored
Document how to disable automatic alphabetical sorting in custom completions
Resolves: #1670
1 parent b378515 commit 60a5efd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

book/custom_completions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ The third line is demonstration of the completion. Type the name of the custom c
3434
When the completion menu is displayed, the prompt changes to include the `|` character by default. This can be changed using `$env.config.menus.marker`.
3535
:::
3636

37+
Note that, by default, the list of completions will be presented in alphabetical order, but sometimes it makes more sense to sort the list differently, e.g. commit hashes from `git log` output.
38+
In this case, to preserve the order of items the completer needs to return a record such as this:
39+
```nu
40+
{options: { sort: false }, completions: ["dog", "cat", "eel" ]}
41+
```
42+
3743
## Modules and Custom Completions
3844

3945
Since completion commands aren't meant to be called directly, it's common to define them in modules.

0 commit comments

Comments
 (0)