Skip to content

bug: x/ansi incorrect calculations of \t #644

@lrstanley

Description

@lrstanley

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions