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

:reflow messes up tab-indented comments #3622

Open
mtoohey31 opened this issue Sep 1, 2022 · 0 comments
Open

:reflow messes up tab-indented comments #3622

mtoohey31 opened this issue Sep 1, 2022 · 0 comments
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug upstream

Comments

@mtoohey31
Copy link
Contributor

mtoohey31 commented Sep 1, 2022

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:

  1. Write the following to a file (ensuring that tab-indentation is used):
// main.go
package main

func main() {
	// Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
	// tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
	// veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
	// commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
	// velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
	// occaecat cupidatat non proident, sunt in culpa qui officia deserunt
	// mollit anim id est laborum.
	println("Hello, world!")
}
  1. hx main.go
  2. Select comment
  3. :reflow 100

I expected this to happen:

The document becomes something like:

package main

func main() {
	// Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
	// ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
	// laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit
	// in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
	// cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
	println("Hello, world!")
}

Instead, this happened:

The document becomes:

package main

func main() {
	// Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod 	// tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim 	// veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea 	// commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
	// velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint 	// occaecat cupidatat non
proident, sunt in culpa qui officia deserunt 	// mollit anim id est laborum.
	println("Hello, world!")
}

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 😬.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants