Skip to content

viewport(v2): Unexpected scrolling behavior with SoftWrap #775

@kamiheku

Description

@kamiheku

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 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

viewport.mp4

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