Repository navigation
Nushell completers in env.nu use the deprecated positional completer input #3127
Description
Describe the bug
The Nushell completers in the generated env.nu receive their input as a positional parameter:
def "nu-complete vp" [context: string] { ... }
def "nu-complete vpr" [context: string] { ... }
Nushell 0.116 gives a completer one record with the fields token, place, and buffer, and it deprecates a positional parameter such as context. The first Tab completion of vp in a new Nushell session shows a nu::shell::deprecated warning. Nushell shows the warning when the line ends, after Enter or Ctrl+C.
Completion still works, because a compatibility bridge still gives context the old value. The warning says that a future Nushell release removes this bridge. After that, Tab completion for vp and vpr can stop working.
The warning gives the migration. Use [buffer, place]. $buffer replaces $context, and $place.cursor replaces its position.
This is the problem in the title of #3092. The body of #3092 describes a different problem, which #3123 fixes.
Reproduction
No repository is necessary. The steps use only vp and nu, and they write only to a temporary directory.
Steps to reproduce
The steps require vp, Nushell 0.116 or later, and fish. The completer calls fish.
-
Generate
env.nuin a temporary directory, so that no real shell profile changes.R=$(mktemp -d) HOME=$R/home ZDOTDIR=$R/home XDG_CONFIG_HOME=$R/config VP_HOME=$R/vp vp env setup --env-only grep -n 'def "nu-complete' "$R/vp/env.nu" -
Run the completer without a terminal.
nu -n -c "source '$R/vp/env.nu'; 'vp en' | commandline complete --detailed | ignore" -
Or start a new interactive session in a terminal.
nu -n -e "source '$R/vp/env.nu'"Type
vp enand press Tab. The line becomesvp env. Then press Enter.
Expected result: Nushell shows no warning.
Actual result: Nushell shows nu::shell::deprecated. The Logs section has the full text. Nushell shows the warning only one time in a session.
This command shows the record that Nushell 0.116 gives to a completer.
nu -n -c "source '$R/vp/env.nu'; 'vp en' | commandline complete --input | to json -r"
# {"token":{"text":"en",...},"place":{"cursor":5,...,"command":["vp","en"]},"buffer":"vp en"}
System Info
vp v1.3.0
Nushell 0.116.1 (aarch64-apple-darwin)
fish 4.9.3
macOSUsed Package Manager
npm
Logs
Warning: nu::shell::deprecated
⚠ Positional completer input deprecated.
╭─[.../vp/env.nu:42:40]
42 │ ╭─▶ def "nu-complete vp" [context: string] {
...
· ╰──── declares the legacy positional input `context`
╰────
help: A parameter completer is handed one record, whose fields bind to the parameters it names: token, place, buffer.
`context` still receives its old positional value for compatibility, but this bridge will be removed in a future
release. To migrate, use `[buffer, place]`; `$buffer` replaces the old context and `$place.cursor` replaces its
position.Validations
- Read the Contributing Guidelines.
- Check that there isn't already an issue for the same bug.
- Confirm this is a Vite+ issue and not an upstream issue (Vite, Vitest, tsdown, Rolldown, or Oxc).
- The provided reproduction is a minimal reproducible example.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Effort
Target date
Start date
Activity