nushell / reedline

A feature-rich line editor - powering Nushell
https://docs.rs/reedline/
MIT License
549 stars 155 forks source link

fix: treat `CTRL + J` as `Enter` #832

Closed ErichDonGubler closed 1 month ago

ErichDonGubler commented 2 months ago

This resolves the issue I noted having in https://github.com/nushell/nushell/issues/6427#issuecomment-1821895162, where hitting Enter in MacOS and Linux outside the main Reedline::read_line call in raw mode results in a CTRL + J event that yields no actual input once read_line is called again.

I'm not positive that this doesn't introduce regressions with, e.g., pasted input. I'm not sure what the best way to test this would be.

I'm also not sure if it resolves that issue in its entirety, since the question of whether its scope should include \n is unresolved.

sholderbach commented 2 months ago

I don't think hardcoding the binding like this is the right move, even if I can see it being part of the default binding. If you use the kitty keyboard extensions it may be possible to bind the true Ctrl-j then you probably want the ability to rewire it.

ErichDonGubler commented 2 months ago

I use Wezterm, so maybe there's some configuration I need to investigate there. I'm not currently aware of a way to rebind keys like that in Wezterm, but admittedly I haven't looked.

ErichDonGubler commented 1 month ago

Thinking about this, IIRC editors like Neovim are often interested in exposing CTRL + J as a separate binding from Enter. I don't know if those sorts of applications are interested in using reedline, but I suppose it does mean that maybe applications should be on the hook for dealing with the distinction.

The application I want to "fix" this in is Nushell; perhaps I should contribute there instead? It is my observation elsewhere that Nushell understands that it's receiving a CTRL + J.

ErichDonGubler commented 1 month ago

Ah, looks like I can resolve this with Nushell configuration: https://github.com/nushell/nushell/issues/6427#issuecomment-2395060695

🫡 Guess I'm done here, sorry for the noise!