mirror of
https://github.com/nushell/nushell.git
synced 2026-10-28 08:54:52 +08:00
Custom completion entry points each had their own calling convention,
so every completer had to work out how to read its input, rebuild
context it was not given, and often call `commandline` to recover
editor state:
parameter completer [context, offset]
command-wide completer [spans]
external completer {|spans| ...}
menu source {|buffer, position| ...}
All four now take the same three named inputs, bound by parameter name
rather than destructured: `token` (the token at the cursor), `place`
(the resolved completion site and its replacement range) and `buffer`
(the command line up to the cursor). A completer declares only the
ones it needs. Prefer `buffer` over calling `commandline`, since
`commandline` can be empty in some editor states, including after `;`.
Ordinary completers run on a background worker with stdin suppressed,
which is correct for normal completion but stops a completer from
driving a terminal picker such as fzf or `input list`. The new
`@interactive` attribute marks a completer that owns the terminal and
runs it inline on the line editor thread instead. That replaces the
experimental `background-completions` option, which was global and
thus all or nothing.
Breaking:
- `background-completions` is removed; `@interactive` is the
per-completer replacement.
- A parameter completer that fails now yields no suggestions, rather
than falling back to completing paths in the working directory.
- Command-wide and external completers may return `null` to decline,
letting file completion or the next source answer.
Migration:
def comp [input pos] -> def comp [token: record]
def comp [spans] -> def comp [buffer: string]
{|spans| ...} -> {|buffer: string| ...}
{|buffer position| ...} -> {|token: record| ...}
background-completions=off -> @interactive on the completer
Completion state is now resolved at the cursor, so nested closures,
aliases, multi-word command heads, flag values and empty argument
slots all complete correctly, and the work no longer clones the whole
engine and stack on every keystroke.
`commandline complete --input` returns the three inputs without
running a completer, which is the supported way to develop one. The
field reference for suggestion records and the `{completions,
options, fallback}` envelope stays in the pull request.
51 lines
1.1 KiB
TOML
51 lines
1.1 KiB
TOML
[files]
|
|
extend-exclude = [
|
|
".git/",
|
|
"crates/nu-command/tests/commands/**",
|
|
"crates/nu-cmd-extra/assets/228_themes.json",
|
|
"tests/fixtures/formats/",
|
|
]
|
|
ignore-hidden = false
|
|
|
|
[default]
|
|
extend-ignore-re = [
|
|
"Plasticos Rival",
|
|
"│ in_custom_valu │",
|
|
"│ ine │",
|
|
":es\\|ful\\(",
|
|
"\\\\u\\{e7ba\\}",
|
|
"([0-9a-f][0-9a-f] ){4}",
|
|
"--find ba\\b",
|
|
"0x\\[ba be\\]",
|
|
"\\)BaR'",
|
|
"fo�.txt",
|
|
# Intentional shortened prefix in completion narrowing tests
|
|
"ls fo",
|
|
"\\*\\.caf=0;38;5;208",
|
|
"\\*\\.hda=0;38;5;208",
|
|
"ue",
|
|
# Intentional partial token and misspelled/unknown keys in completer tests
|
|
"na\\.fo",
|
|
"\\{token: fo",
|
|
"na, fo",
|
|
"strat: 3",
|
|
"discription: hi",
|
|
"fiter: false",
|
|
]
|
|
|
|
[type.rust.extend-words]
|
|
nd = "nd"
|
|
typ = "typ"
|
|
numer = "numer"
|
|
styl = "styl"
|
|
|
|
[default.extend-identifiers]
|
|
ratatui = "ratatui"
|
|
enabled_indented_mutiline_value = "enabled_indented_mutiline_value"
|
|
# unicode general category, "number, decimal digit"
|
|
Nd = "Nd"
|
|
|
|
[default.extend-words]
|
|
ratatui = "ratatui"
|
|
abd = "abd"
|