charmbracelet / charmbracelet/bubbletea

Pager example with high performance rendering loses first line on resize

Open
#1,039 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
45k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
I'm running the pager example, albeit with high performance rendering turned on. It works fine until the window is resized, at which point the first line of the viewport is 'lost', i.e. it is re-rendered as an empty line.

**Setup**
- Arch
- Bash
- Alacritty

**To Reproduce**
Steps to reproduce the behavior:
1. go to `./examples/pager`
2. edit `main.go` to enable high performance renderer:

```diff --git a/examples/pager/main.go b/examples/pager/main.go
index 12a71a3..fd677d5 100644
--- a/examples/pager/main.go
+++ b/examples/pager/main.go
@@ -19,7 +19,7 @@ import (
// Also keep in mind that high performance rendering only works for programs
// that use the full size of the terminal. We're enabling that below with
// tea.EnterAltScreen().
-const useHighPerformanceRenderer = false
+const useHighPerformanceRenderer = true
```

3. run: `go run main.go`
4. resize terminal window

**Screenshots**
Before resize:

![image](https://github.com/charmbracelet/bubbletea/assets/75728/550bf46a-259a-4163-974b-0f18e3f95e5a)
After resize:

![image](https://github.com/charmbracelet/bubbletea/assets/75728/46dee84a-c642-4cc4-aebb-361b3dcfe0be)

**Further info**

The line does reappear if you scroll down and then back up again.

It also re-appears if you full screen the terminal and then un-fullscreen the terminal.

If you scroll down before a window resize, and then resize the window, then the first *visible* line is missing and stays missing until you scroll it out of view and back into view.

Contributor guide

Open the contributing guide

Research direction

Start in examples/pager/main.go, enable useHighPerformanceRenderer, and run go run main.go from ./examples/pager. Resize the terminal and compare the first visible line before and after resizing, including after scrolling. Done means the first visible line remains rendered after resize and still behaves correctly when scrolling.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.