charmbracelet / charmbracelet/bubbles

viewport(v2): Unexpected scrolling behavior with `SoftWrap`

Open
#775 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
8.9k
Forks
457
Avg merge
1d 18h
Merged PRs (30d)
5

Description

**Describe the bug**

Scrolling a `Viewport` up or down with `SoftWrap` enabled feels broken.

As an example, when a single line has been wrapped to span **six** logical / visual lines, the user must press `j/↓` **five** times in order to achieve **any** scrolling of the viewport.

**Setup**

macOS, WezTerm, `v2` dependencies:

```
github.com/charmbracelet/bubbles/v2 v2.0.0-beta.1
github.com/charmbracelet/bubbletea/v2 v2.0.0-beta1
```

**To Reproduce**

Steps to reproduce the behavior:
1. Create a `Viewport` with content that has lines exceeding the width of the viewport
2. Turn `SoftWrap` on
3. Scroll vertically past soft linebreaks -- multiple key presses are required for a view update

**Source Code**

See [this gist](https://gist.github.com/kamiheku/42910205f91a37ffade3833efa80d52c) for a quick repro.

Pressing `w` toggles `SoftWrap` on and off.

**Expected behavior**

I would expect the viewport scrolling to happen by _logical_ lines. That is, pressing `j` once should **immediately** scroll the topmost (wrapped) line of content out of view.

**Screenshots**

https://github.com/user-attachments/assets/fc245930-93f3-4023-82be-5f2fb1104ea8

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.