Repository navigation
fix(completions): keep the REPL usable when a completer runs fzf or input list - #18881
Merged
fdncred merged 4 commits intoAug 22, 2026
Merged
Conversation
# Conflicts: # crates/nu-cli/src/completions/completer.rs
Merged
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
Tab completion and custom menus were fighting interactive pickers (
fzf,input list) for the terminal. That is #18879.Tab runs
NuCompleteron a background worker withsuppress_stdin. That isolation is right for carapace-style completers that only print a list. It is wrong for a completer that needs the TTY:input listhitrequire_stdinand declined, so Tab fell back to file completion.^fzfwith a piped candidate list skippedsetsid, opened/dev/ttyon the worker, and raced reedline. The prompt hung after fzf exited.Ctrl+T goes through a menu
sourceon the REPL thread, so fzf already worked there.input listdid not: it alwaysdisable_raw_mode()on the way out, even when reedline already had raw mode on. Backspace then died inside the sameread_line.External-arg Tab is now blocking by design whenever a completer closure is configured. That is the same path fzf needs. Call it out in the release notes so Carapace configs are not a surprise.
ReplTerminalGuardonly restores raw mode after that closure. It does not re-enable bracketed paste or the kitty keyboard protocol. Reedline turns those on atread_linestart; they are ANSI modes, not termios. Carapace does not touch them. Fzf might. If paste-after-fzf on the same prompt misbehaves, a follow-up should emitEnableBracketedPaste/ kitty push from the guard using$env.config.bracketed_pasteanduse_kitty_protocol.User-facing changes (Release notes)
Interactive pickers in completions
Tab completion can run an interactive picker from
$env.config.completions.external.completer(and from custom@comp/@completeclosures). Closures such as fzf orinput listtake the TTY while the line editor waits. Completers that only print a list should still return quickly.After
input list(or a similar picker) returns from a completion or a custom menu, the prompt keeps raw mode. Backspace and other editing keys work again.Subprocesses spawned from a background completion thread stay detached from the terminal even when their stdin is a pipe, so they cannot steal the TTY from the line editor.
Tab waits for the external completer
When
$env.config.completions.external.completeris set, Tab on an external command waits for that closure before the line editor continues. That lets a picker such as fzf orinput listtake the terminal. Completers that only print a list (for example Carapace) should return quickly; a slow closure freezes the prompt until it finishes.File and command-name completion still run in the background. Custom menu
sourceclosures were already synchronous.To make every Tab wait, not only user completers:
Results from the external completer and from
@comp/@completeare not cached, so a picker runs again on the next Tab.Additional notes
closes #18879
closes #18771