-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
:reflow
messes up tab-indented comments
#3622
Labels
Comments
rhogenson
pushed a commit
to rhogenson/helix
that referenced
this issue
Sep 21, 2024
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 helix-editor#3332, helix-editor#3622
rhogenson
pushed a commit
to rhogenson/helix
that referenced
this issue
Sep 21, 2024
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 helix-editor#3332, helix-editor#3622
rhogenson
pushed a commit
to rhogenson/helix
that referenced
this issue
Sep 21, 2024
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 helix-editor#3332, helix-editor#3622
rhogenson
pushed a commit
to rhogenson/helix
that referenced
this issue
Sep 21, 2024
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 helix-editor#3332, helix-editor#3622
rhogenson
pushed a commit
to rhogenson/helix
that referenced
this issue
Sep 22, 2024
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
rhogenson
pushed a commit
to rhogenson/helix
that referenced
this issue
Sep 22, 2024
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
rhogenson
pushed a commit
to rhogenson/helix
that referenced
this issue
Sep 22, 2024
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
rhogenson
pushed a commit
to rhogenson/helix
that referenced
this issue
Sep 22, 2024
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
Summary
When
:reflow
is used with comments that are indented via spaces, it correctly maintains the common prefix on all lines. However, with tabs, it treats the tabs and the comment prefix as if they were regular characters, and ends up breaking the comment.Reproduction Steps
I tried this:
hx main.go
:reflow 100
I expected this to happen:
The document becomes something like:
Instead, this happened:
The document becomes:
Helix log
No response
Platform
Linux
Terminal Emulator
kitty 0.25.2
Helix Version
22.05-440-ge0667827
Edit: I am working on a fix for this, just thought I'd post this for a clear explanation of the motivation for the eventual PR.
Edit 2: Also, now that I've looked into the code, it looks like tab-width is totally unaccounted for too. Tabs currently count as zero width 😬.
The text was updated successfully, but these errors were encountered: