charmbracelet / charmbracelet/x
bug: x/ansi incorrect calculations of \t
- Dominant language
- Go
- Stars
- 314
- Forks
- 94
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 2
Description
### Description
Currently, `ansi.StringWidth()`, `ansi.StringWidthWc()`, etc, incorrectly calculate `\t` (tab) characters. I am not sure if this is intended behavior or not. If it is, documentation should probably be updated to make it clear that users should strip those values out of their input.
Example test:
```go
package main
import (
"fmt"
"github.com/charmbracelet/x/ansi"
)
func main() {
fmt.Println(ansi.StringWidth("\t"))
}
```
Returns `0`. Using `\ttest` returns `4`.
### Version
master
### Environment
Linux (Windows 11 & WSL2) / Windows Terminal / na
Contributor guide
Research direction
Start with the ansi.StringWidth and ansi.StringWidthWc entry points and run the provided Go example to reproduce the tab-width discrepancy. Determine the intended handling of tab characters, then make the width calculation or documentation consistent and add coverage for both "\t" and "\ttest".
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100