Skip to content

fix(completions): keep the REPL usable when a completer runs fzf or input list - #18881

Merged
fdncred merged 4 commits into
nushell:mainfrom
fdncred:fix_async_completions_with_fzf_inputlist
Aug 22, 2026
Merged

fdncred merged 4 commits into
nushell:mainfrom
fdncred:fix_async_completions_with_fzf_inputlist

Conversation

@fdncred

@fdncred fdncred commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Description

Tab completion and custom menus were fighting interactive pickers (fzf, input list) for the terminal. That is #18879.

Tab runs NuCompleter on a background worker with suppress_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 list hit require_stdin and declined, so Tab fell back to file completion.
  • ^fzf with a piped candidate list skipped setsid, opened /dev/tty on the worker, and raced reedline. The prompt hung after fzf exited.

Ctrl+T goes through a menu source on the REPL thread, so fzf already worked there. input list did not: it always disable_raw_mode() on the way out, even when reedline already had raw mode on. Backspace then died inside the same read_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.

ReplTerminalGuard only restores raw mode after that closure. It does not re-enable bracketed paste or the kitty keyboard protocol. Reedline turns those on at read_line start; 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 emit EnableBracketedPaste / kitty push from the guard using $env.config.bracketed_paste and use_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 / @complete closures). Closures such as fzf or input list take 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.completer is set, Tab on an external command waits for that closure before the line editor continues. That lets a picker such as fzf or input list take 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 source closures were already synchronous.

To make every Tab wait, not only user completers:

nu --experimental-options '[background-completions=false]'

Results from the external completer and from @comp / @complete are not cached, so a picker runs again on the next Tab.

Additional notes

closes #18879
closes #18771

@fdncred
fdncred merged commit 1e6f2d2 into nushell:main Aug 22, 2026
14 checks passed
@fdncred
fdncred deleted the fix_async_completions_with_fzf_inputlist branch August 22, 2026 16:32
@github-actions github-actions Bot added this to the v0.116.0 milestone Aug 22, 2026
@fdncred fdncred added A:completions Issues related to tab completion notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes labels Aug 22, 2026
@cptpiepmatz cptpiepmatz modified the milestones: v0.116.0, v0.115.1 Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:completions Issues related to tab completion notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes

Projects

None yet

2 participants