#1822·bubbletea

[v2] 多屏幕 Println 会删除已渲染的内联 View

作者: rsbin1178创建于 2026年9月29日更新于 2026年9月29日

Describe the bug

In inline mode, one tea.Println containing more rows than the terminal can accommodate above the managed View removes the already-rendered View. The View stays byte-for-byte identical throughout the reproduction. This occurs after the initial frame is visibly rendered, with no resize, model switch, streaming, raw terminal output, or clear-screen operation. All printed lines are short ASCII strings, so this is not a wrapping or wide-grapheme case. I reproduced it with the latest release, charm.land/bubbletea/v2 v2.0.10, and with the renderer/Program source from current main (ff51ba4c51f85875761b15a64f9ab9aa0eaa9fa1). The renderer file on that commit is identical to v2.0.10; the additional main-branch change concerns shutdown signal handling. Setup - OS: macOS 26.5.1, arm64 - Go: go1.26.6 darwin/arm64 - Reproduction environment: a local controlling PTY at 40 columns × 10 rows, whose output is replayed in pyte 0.8.2 for screen/history assertions - Environment: TERM=xterm-256color, TERM_PROGRAM=Apple_Terminal, NO_COLOR=1. The TERM_PROGRAM value is an explicit harness setting, not a claim that the test ran in the Apple Terminal GUI. - Shell: the harness launches the compiled binary directly; no shell is involved - SSH / terminal multiplexer: none - Also observed with renderer-level screen assertions using GitHub.com/charmbracelet/x/vt To Reproduce 1. Put the source below in main.go in a new directory and run: sh go mod init bubbletea-inline-repro go get charm.land/bubbletea/[email protected] go run . 2. Use a 40×10 terminal, or a terminal substantially shorter than the 80 printed rows. 3. Wait until COMPOSER, STATUS, and the key hint are visible. This matters: the example does not print from Init, and the first View has already been painted. 4. Press p once. 5. Observe the screen before pressing q, since shutdown may repaint the View. Source Code go package main import ("fmt" "os" "strings") import ("tea" "charm.land/bubbletea/v2") type model struct{} func (model) Init() tea.Cmd { return nil } func (m model) Update(message tea.Msg) (tea.Model, tea.Cmd) { if key, ok := message.(tea.KeyPressMsg); ok { switch key.String() { case "p": lines := make([]string, 80) for i := range lines { lines[i] = fmt.Sprintf("ROW-%03d", i) } return m, tea.Println(strings.Join(lines, "\n")) case "q", "ctrl+c": return m, tea.Quit } } return m, nil } func (model) View() tea.View { view := tea.NewView("COMPOSER\nSTATUS\np: print history | q: quit") view.Cursor = tea.NewCursor(0, 0) return view } func main() { if _, err := tea.NewProgram(model{}).Run(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } Expected behavior - ROW-000 through ROW-079 enter native history exactly once and in order. - The three-line managed View remains visible beneath that output. - The visible Cursor is restored to the View's requested position.

内容来源: charmbracelet/bubbletea