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

ansi: inconsistent handling of tabs #237

Closed
pachecot opened this issue Nov 2, 2024 · 1 comment · Fixed by #238
Closed

ansi: inconsistent handling of tabs #237

pachecot opened this issue Nov 2, 2024 · 1 comment · Fixed by #238
Assignees
Labels
bug Something isn't working

Comments

@pachecot
Copy link
Contributor

pachecot commented Nov 2, 2024

ansi.StringWidth treats tabs as zero width, but ansi.Harwrap treats tabs a non-zero width of 1.

one would get would unexpected results with a construct such as this :

	s := "foo\tbar"
	n := ansi.StringWidth(s)           // n == 6
	p := ansi.Hardwrap(s, n, true)

	// p == "foo\tba\nr"   
	// not  "foo\tbar" as one might expect 

not sure if this is a bug or intended behavior.

one of the tests for Hardwrap is..

	{"tab", "foo\tbar", 3, "foo\n\tba\nr", true},
@aymanbagabas aymanbagabas added the bug Something isn't working label Nov 4, 2024
@aymanbagabas aymanbagabas self-assigned this Nov 4, 2024
aymanbagabas added a commit that referenced this issue Nov 4, 2024
Tabs should be treated as zero-width characters when wrapping text.

Fixes: #237
@aymanbagabas
Copy link
Member

Thank you, @pachecot, for opening this issue. I've opened #238 to patch this one 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants