Skip to content

Implemented the "press Enter twice to end list/comment" feature#15299

Open
guttermonk wants to merge 1 commit intohelix-editor:masterfrom
guttermonk:master
Open

Implemented the "press Enter twice to end list/comment" feature#15299
guttermonk wants to merge 1 commit intohelix-editor:masterfrom
guttermonk:master

Conversation

@guttermonk
Copy link

Closes #14209

Current recipe (in languages.toml):

[[language]]
name = "markdown"
comment-tokens = ["-", "+", "*", "- [ ]", ">"]

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-tokens for 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:

  1. open_below/open_above (~line 3683) — triggered by o/O in normal mode
  2. Insert mode Enter (~line 4298) — triggered by pressing Enter while typing

Both 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:

  1. Remove the empty bullet from the current line
  2. Insert a plain newline (no token)

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.

[Feature Request] Improvement to the Continue Markdown Lists / Quotes recipe.

1 participant