Skip to content

v2: tab characters are not preservedΒ #1541

@ansel1

Description

@ansel1

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

package main

import (
	"github.com/charmbracelet/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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions