charmbracelet/bubbletea

text rendering incorrectly using serial data

Horryportier opened this issue · 7 comments

Describe the bug
text dose not render correctly when inserting longer line

Setup
Please complete the following information along with version numbers, if applicable.

  • OS [e.g. Pop OS]
  • Shell [e.g. bash]
  • Terminal Emulator [e.g. wezterm]
  • Terminal Multiplexer [e.g. wezterm workspaces ]

To Reproduce
i have text value that i append to data from serial port and its displayed

Source Code
https://github.com/Horryportier/go-serial-tui/blob/main/main.go

Expected behavior
content should not disappear whenever longer line is append. from my test's when not using data from serial it works without any issues

Screenshots
https://github.com/charmbracelet/bubbletea/assets/42907709/f60e8030-80da-46a3-bd8e-7f7bead8d006

You need to wrap your content at the given maximum width.

#43 looked at this issue and added wrapping using github.com/muesli/reflow/wordwrap package yet it still has that weird despairing bug although text appears when i add long enough string so wordwrap triggers and then all seems to stay on screen from that point on

#43 looked at this issue and added wrapping using github.com/muesli/reflow/wordwrap package yet it still has that weird despairing bug although text appears when i add long enough string so wordwrap triggers and then all seems to stay on screen from that point on

I'm experiencing this exact bug. I thought about calling

import (
	"github.com/inancgumus/screen"
)

func clearScreen() {
	screen.Clear()
	screen.MoveTopLeft()
}

in the beginning of View() but https://pkg.go.dev/github.com/charmbracelet/bubbletea#ClearScreen states: "Note that it should never be necessary to call ClearScreen() for regular redraws." So I think there must be a better way to fix this. Did you figure something out by now?

Hi! @Horryportier or @m1cm1c: can you produce a minimal example, with reflow, that reproduces the issue? That will help us solve this quickly and effectively. If the bug you're seeing is in reflow itself, let's close this issue and open an issue there.

I don't thing reflowis the issue, bug was present before I've added that library. Wordwrap solved issue partially because it still would occurred for strings shorter that wrap threshold but it would fix itself after wordwrap was triggered

As for reproducing the bug it would hard because it only occurs for me when dealing with text data from serial port. So there might be issue with data send from esp32 having some weird glyphs. Although arduino ide 2 works just fine.

@meowgorithm Here is a fairly small program that reliably reproduces the described behavior: https://gist.github.com/m1cm1c/0248ef748db56d0cc1f7e4398a3f2fad

I ran it via: go run .

Initial state (looks fine):
image

After making the window wider (looks fine):
image

After making the window narrower again, "(esc to quit)" repeats:
image

OS: Manjaro
Go version: 1.21.7
Architecture: AMD64
Terminal: xfce4-terminal (version 1.1.3)
Shell: GNU bash (version 5.2.26(1))

that looks like different bug than mine mine makes first few characters disappear corresponding to amount of additional text
image
image
image