reedline icon indicating copy to clipboard operation
reedline copied to clipboard

Add ReedlineEvent::SubmitOrSpace

Open zknx opened this issue 2 months ago • 3 comments

This PR solves https://github.com/nushell/nushell/issues/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.

zknx avatar Oct 24 '25 15:10 zknx

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

fdncred avatar Oct 24 '25 16:10 fdncred

@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 avatar Oct 24 '25 16:10 zknx

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.

zknx avatar Oct 24 '25 16:10 zknx