#19016·nushell

External completer migration from #18791 completes the wrong command after a pipe

Author: kronberger-droidCreated Sep 12, 2026Updated Sep 16, 2026
Labelsstatus:needs-triage

Bug report form

  • I have done a basic search of the issue tracker to find any existing issues that are similar.
  • I have checked that my version is at least the latest stable release available via my installation method.

Describe the bug

buffer is the whole command line up to the cursor, and the external-completer migration shown in #18791 splits it and takes the first word. After a pipe, or inside a closure or subexpression, that first word is not the command being completed, thus the completer is handed the wrong command.

The old spans did not have this, since it only ever held the current element's tokens.

How to reproduce

repro.nu:

nu
$env.config.completions.external.completer = {|buffer|
  let words = $buffer | split row " "
  [$"would complete: ($words | first)"]
}
  1. source repro.nu
  2. type cargo bui, press Tab, the menu shows would complete: cargo
  3. type ls | cargo bui, press Tab, the menu shows would complete: ls

echo (cargo bui and do { cargo bui give echo and do the same way.

Expected behavior

would complete: cargo in all cases, since that is the call the cursor is in.

For |, ( and { a completer can work around it with std structure, cutting at the last pipe, block or closure token. That is not writable for ;, since std structure emits no token for the separator:

> std structure "ls; cargo bui" | select text kind
[{text: ls, kind: internalcall}, {text: cargo, kind: external}, {text: bui, kind: externalarg}]

while commandline complete --input on the same line resolves external-arg index 0 correctly, thus the engine has the element and the completer cannot get at it.

Configuration

key value
version 0.115.2
major 0
minor 115
patch 2
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.97.1 (8bab26f4f 2026-07-14) (built from a source tarball)
cargo_version cargo 1.97.0 (c980f4866 2026-06-30)
build_time 1980-01-01 00:00:00 +00:00
build_rust_channel release
allocator standard
features default, lsp, mcp, network, plugin, rustls-tls, sqlite, trash-support
installed_plugins
experimental_options example=false, dc-glob=false, reorder-cell-paths=true, pipefail=true, enforce-runtime-annotations=true, native-clip=false, cell-path-types=false