charmbracelet / charmbracelet/bubbletea

v2: tab characters are not preserved

Open
#1,541 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
44.9k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Tab characters in string views seem to be omitted.

**Setup**
macOS, nushell, ghostty 2

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Source Code**
```go
package main

import (
"charm.land/bubbletea/v2"
)

type model struct {
}

func (m *model) Init() tea.Cmd {
return nil
}

func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "q", "esc", "ctrl+c":
return m, tea.Quit
}
}
return m, nil
}

func (m *model) View() tea.View {
return tea.NewView("Hi there")
}

func main() {
p := tea.NewProgram(&model{})
p.Run()
}
```

**Expected behavior**
Expected behavior would be to print out a tab character between "Hi" and "there", something like:

```
Hi there
```

Instead it prints out:

```
Hithere
```

**Screenshots**

Image

**Additional context**
In the debugger, I tracked this down as far as github.com/charmbracelent/ultraviolet/styled.go#printString, around this code:

Image

The cell's contents are set to the "\t" character, but that cell is not set in the screen. In the next loop, the cell's contents are overwritten with the next character.

Contributor guide

Open the contributing guide

Research direction

Start in github.com/charmbracelet/ultraviolet/styled.go at printString, then run the supplied Go reproduction to observe how the tab in tea.NewView("Hi\tthere") is rendered. Done means the tab produces visible spacing between “Hi” and “there” without the following character overwriting its cell.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.