Skip to content

Fix stale $env in the parser and completer after overlay use inside a block - #19458

Merged
fdncred merged 2 commits into
nushell:mainfrom
fdncred:overlay_block_pwd
Nov 12, 2026
Merged

fdncred merged 2 commits into
nushell:mainfrom
fdncred:overlay_block_pwd

Conversation

@fdncred

@fdncred fdncred commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Description

With if (which opam | is-not-empty) { overlay use opam } in config.nu, Tab completion stays on the directory nu started in, wherever you cd, while $env.PWD, pwd and ls are correct.

The parser drops an overlay command's effect when the enclosing block ends, but the stack keeps it, so the two disagree about which overlays are active. cd and $env.FOO = ... write through the stack's list. EngineState::get_env_var, which the parser and the completer rely on, reads through the parser's list, so it misses those values and finds older ones below them. overlay hide inside a block goes wrong the same way in reverse.

merge_env now remembers the stack's list when it differs from the parser's, and get_env_var and render_env_vars read through it. When the lists agree, which is the normal case, they read the same overlays as before.

User-facing changes (Release notes)

  • Fixed Tab completion, relative use, const path commands and the cwd saved in sqlite history using the startup directory after an overlay command inside a block, such as if $x { overlay use spam }.
  • Fixed $env.NU_LIB_DIRS and other variables the parser reads being ignored when set after an overlay command inside a block.

Additional notes

@fdncred fdncred added notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes and removed status:wait-until-after-nushell-release labels Nov 12, 2026
@fdncred
fdncred merged commit 6172c35 into nushell:main Nov 12, 2026
12 checks passed
@fdncred
fdncred deleted the overlay_block_pwd branch November 12, 2026 12:03
@github-actions github-actions Bot added this to the v0.118.0 milestone Nov 12, 2026
fdncred pushed a commit that referenced this pull request Nov 15, 2026
…9543)

## Description

Fixes #11570

Add overlay-name completion for `overlay hide` using the existing
built-in completion framework.

Suggestions include overlays active in both the runtime stack and the
permanent parser state, excluding the default `zero` overlay. Using the
permanent parser state keeps the current target available even when the
temporary completion parse has already hidden it.

Completion matches decoded names and quotes them when needed for
insertion. Suggestions remain available while typing unfinished
double-quoted escapes. Results are not cached across prompts, so
activating or hiding an overlay is reflected in subsequent completions.

```nu
overlay new spam
"overlay hide sp" | commandline complete
# => [spam]
```

## User-facing changes (Release notes)

`overlay hide` now completes active overlay names, including names that
require quoting.

## Additional notes

- Regression coverage includes empty and partial input, hidden overlays,
parser/runtime disagreements, quoting, incomplete escapes, replacement
spans, Unicode, flags, and overlay changes across prompts.
- Escape-sensitive tests apply and execute the completed command.
- On macOS arm64, all 428 CLI unit tests and 394 CLI integration tests
passed, with two existing integration tests ignored.
- Both Clippy checks, formatting, `typos`, and whitespace checks passed.
- Built the executable and verified completion through `commandline
complete`. Windows/Linux execution, the full workspace suite, and manual
Tab-menu verification of this revision remain unverified.
- Tracking earlier unexecuted commands in the buffer and fixing the
underlying parser/runtime discrepancy from #19458 remain outside this
change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant