Repository navigation
Fix stale $env in the parser and completer after overlay use inside a block - #19458
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
With
if (which opam | is-not-empty) { overlay use opam }inconfig.nu, Tab completion stays on the directory nu started in, wherever youcd, while$env.PWD,pwdandlsare 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.
cdand$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 hideinside a block goes wrong the same way in reverse.merge_envnow remembers the stack's list when it differs from the parser's, andget_env_varandrender_env_varsread through it. When the lists agree, which is the normal case, they read the same overlays as before.User-facing changes (Release notes)
use, const path commands and thecwdsaved in sqlite history using the startup directory after an overlay command inside a block, such asif $x { overlay use spam }.$env.NU_LIB_DIRSand other variables the parser reads being ignored when set after an overlay command inside a block.Additional notes
nu --lsp,nu --mcpandnu --daprun the startup files on a stack they then discard, so they call the newEngineState::clear_runtime_overlaysand behave as they do on main.