Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enter newline if cursor position is middle of input #802

Conversation

ima1zumi
Copy link
Member

@ima1zumi ima1zumi commented Jan 5, 2025

I have changed the Enter key behavior so that pressing Enter in the middle of a line adds a new line even if the input can be confirmed. Pressing Enter at the end of a line will confirm the input as before.
If you prefer the previous behavior, you can set ed_force_newline in inputrc to allow confirmation when pressing Enter in the middle of a line. The existing Alt+Enter functionality remains unchanged.

CleanShot.2025-01-05.at.17.32.26.mp4

@ima1zumi ima1zumi marked this pull request as ready for review January 5, 2025 14:45
@ima1zumi ima1zumi added the enhancement New feature or request label Jan 5, 2025
end
end
else
finish
end
end

private def ed_force_newline(_key)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like force_newline force enter newline character instead of finish for me.
How about a name like force_finish or force_submit (the word submit is not use in reline, though)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I have renamed ed_force_submit. Since this is a name that users can use, I thought submit would be easier to understand.

@ima1zumi ima1zumi force-pushed the enter-newline-if-cursor-position-is-middle-of-input branch from 4b662d8 to 9557354 Compare January 6, 2025 14:54
Copy link
Member

@tompng tompng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍
Let's try it!

@tompng tompng merged commit 8ef534e into ruby:master Jan 6, 2025
45 checks passed
matzbot pushed a commit to ruby/ruby that referenced this pull request Jan 6, 2025
(ruby/reline#802)

* Enter newline if cursor position is middle of input

* Add ed_force_submit to allow input confirmation on non-final lines

ruby/reline@8ef534e904
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants