Skip to content

Conversation

@zknx
Copy link

@zknx zknx commented Oct 24, 2025

This PR solves nushell/nushell#9227 without changing the default behavior.

Context

The issue reports that when tab completion is active, pressing space doesn't accept the currently selected option (unlike pressing Enter). Instead, the completion menu persists, which differs from the expected behavior in most shells.

I've been struggling with this issue myself. While it seems most users haven't encountered it, I'll leave it up to you whether to approve this change.

What this PR does

With this fix, pressing space during tab completion will accept the current selection and close the completion menu.
Example with nushell:

$env.config.keybindings ++= [
  {
    name: submit_or_space
    modifier: none
    keycode: space
    mode: [emacs vi_normal vi_insert]
    event: [
      {send: SubmitOrSpace}
    ]
  }
]
touch a1 a2
cat a<tab><space>

will update the buffer to:

cat a1 [cursor here]

similar to the behavior in zsh or fish or pwsh.

@fdncred
Copy link
Contributor

fdncred commented Oct 24, 2025

How does that work when completing paths with spaces in them?

@zknx
Copy link
Author

zknx commented Oct 24, 2025

@fdncred Hi, thanks for checking this. I did some test:

$ touch "aaa 111" "aaa 222"
$ cat a<tab><space>

makes

$ cat `aaa 111` [cursor here]
$ touch "b 10" "b 11" "b 20" "b 21"
$ cat "b <tab><space>

makes

$ cat `b 10` [cursor here]

@zknx
Copy link
Author

zknx commented Oct 24, 2025

Ok, if I enabled this, it breaks like

$ cat "b<tab><space>2<enter>

cz I cannot input <space> character after I press <tab> key.
So it breaks something and shouldn't become default behavior.

@fdncred fdncred marked this pull request as draft November 3, 2025 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants