Implemented the "press Enter twice to end list/comment" feature#15299
Open
guttermonk wants to merge 1 commit intohelix-editor:masterfrom
Open
Implemented the "press Enter twice to end list/comment" feature#15299guttermonk wants to merge 1 commit intohelix-editor:masterfrom
guttermonk wants to merge 1 commit intohelix-editor:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #14209
Current recipe (in
languages.toml):This cleverly repurposes the "toggle comment" continuation behavior to auto-insert list markers when you press Enter/
o. But the problem is: pressing Enter twice still adds another bullet, so you have to manually delete it to end the list.The issue is that this is a bit of a hack — it's using
comment-tokensfor something they weren't designed for. The "press Enter twice to stop" behavior would need to be built into Helix's comment continuation logic itself (detecting an empty comment line and removing it).So here's my honest take:
This isn't really something that can be fixed with a better recipe/config — it's a core Helix feature request. The comment continuation engine would need to detect "if the previous line is just a bare bullet with no content, remove it instead of adding another." That's code-level, not config-level.
The architecture:
There are two code paths that continue comments, both in
helix-term/src/commands.rs:open_below/open_above(~line 3683) — triggered byo/Oin normal modeBoth paths call
comment::get_comment_token()to check if the current line starts with a comment token (like-,*,>). If it does, they prepend that token to the new line.What needed to change:
In both paths, before inserting the continuation token, check: is the current line only the comment token (plus whitespace)? If so, instead of continuing, it should: