[PR #581] [MERGED] Fix inverted handling of KeyPgDn/KeyPgUp in List widget #988

Closed
opened 2026-03-04 01:08:53 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/rivo/tview/pull/581
Author: @berrange
Created: 3/15/2021
Status: Merged
Merged: 4/26/2021
Merged by: @rivo

Base: masterHead: pg-keys


📝 Commits (1)

  • 0bca6da Fix inverted handling of KeyPgDn/KeyPgUp in List widget

📊 Changes

1 file changed (+6 additions, -0 deletions)

View changed files

📝 list.go (+6 -0)

📄 Description

Consider a list with 5 items, and the currentItem index is 2, and
all items fit on the screen without scrolling.

KeyPgDn will set currentItem to 7 which is out of bounds, and
gets wrapped around to 0.

KeyPgUp will set currentItem to -3 which is out of bounds, and
gets wrapped around to 4.

Thus PgDn selects the first item, while PgUp selects the last item,
which is the opposite of expected behaviour for these keys. Fix
this by clamping currentItem to the boundaries in the key handler.

Fixes: https://github.com/rivo/tview/issues/580
Signed-off-by: Daniel P. Berrangé berrange@redhat.com


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/rivo/tview/pull/581 **Author:** [@berrange](https://github.com/berrange) **Created:** 3/15/2021 **Status:** ✅ Merged **Merged:** 4/26/2021 **Merged by:** [@rivo](https://github.com/rivo) **Base:** `master` ← **Head:** `pg-keys` --- ### 📝 Commits (1) - [`0bca6da`](https://github.com/rivo/tview/commit/0bca6dadb36d53f1be2c666147c6a7c413e69149) Fix inverted handling of KeyPgDn/KeyPgUp in List widget ### 📊 Changes **1 file changed** (+6 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `list.go` (+6 -0) </details> ### 📄 Description Consider a list with 5 items, and the currentItem index is 2, and all items fit on the screen without scrolling. KeyPgDn will set currentItem to 7 which is out of bounds, and gets wrapped around to 0. KeyPgUp will set currentItem to -3 which is out of bounds, and gets wrapped around to 4. Thus PgDn selects the first item, while PgUp selects the last item, which is the opposite of expected behaviour for these keys. Fix this by clamping currentItem to the boundaries in the key handler. Fixes: https://github.com/rivo/tview/issues/580 Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 01:08:53 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#988
No description provided.