Commit ca60277
authored
Allow setting span in custom/extern completers (nushell#15888)
# Description
Closes nushell#15863. This PR allows
custom and extern completers to set the `span` field for the
`Suggestion`s they provide.
The motivation for this is mainly making it easier to make completers
for Zoxide.
# Release notes summary
Custom completers and external completers will be able to choose which
part of the buffer to replace. This is useful if you also want to
replace one of the previous arguments to a command, or if you only want
to replace part of an expression.
# Tests + Formatting
Didn't add any tests, but did manually try the following:
```
> def comp [context, pos] { [{value: mwahahaha, description: bar, span: {start: 0, end: $pos}}] }
> def foo [arg: string@comp] {}
```
After creating those definitions, `foo <TAB>` will replace the command
line with `mwahahaha`.
# After Submitting
Needs to be mentioned in the completer docs.1 parent a59ac4d commit ca60277
File tree
2 files changed
+52
-1
lines changed- crates/nu-cli
- src/completions
- tests/completions
2 files changed
+52
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
936 | 936 | | |
937 | 937 | | |
938 | 938 | | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
939 | 957 | | |
940 | 958 | | |
941 | 959 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
275 | 294 | | |
276 | 295 | | |
277 | 296 | | |
| |||
797 | 816 | | |
798 | 817 | | |
799 | 818 | | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
800 | 833 | | |
801 | 834 | | |
802 | 835 | | |
| |||
0 commit comments