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

Handle single-line comment prefixes in :reflow. #11738

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rhogenson
Copy link
Contributor

This uses the single-line comment prefixes from the language config, so it should be able to handle different languages in a robust way. The logic is fairly simple, and doesn't handle block comments, for example.

Fixes #3332, #3622

Thanks for all your work on this editor, it is a joy to use.

@pascalkuthe
Copy link
Member

We want to move away from textwrap to our own wrapping system. That will allow us to implement these kind of thjngs without resorting to hacks.

@the-mikedavis
Copy link
Member

In particular see #3332 (comment)

@rhogenson
Copy link
Contributor Author

rhogenson commented Sep 21, 2024

Makes sense. Let me see if I can reuse the existing softwrap implementation instead of textwrap.

@rhogenson
Copy link
Contributor Author

I integrated the reflow logic into DocumentFormatter so that we can reuse the existing soft-wrap logic. This does mean that :reflow always preserves existing newlines, so it no longer allows reflowing out to a larger width, but it also makes it more consistent and probably accidentally addresses #2419

I changed :reflow to use the DocumentFormatter object instead of the
textwrap crate. This allows using the same logic for soft wrap as
for :reflow. Because the logic is the same as for soft wrap, we end up
preserving all existing newlines, so it's more like "wrap" than reflow,
but I think this behavior makes sense anyway to avoid extraneous diffs.

Fixes helix-editor#3332, helix-editor#3622
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.

Reflow doesn't work consistently with comments
3 participants