[PR #218] [CLOSED] Do not scroll List items unless selected item is out of view #882

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

📋 Pull Request Information

Original PR: https://github.com/rivo/tview/pull/218
Author: @ardnew
Created: 1/3/2019
Status: Closed

Base: masterHead: list-viewtracking


📝 Commits (1)

  • d3867f3 change: implemented view tracking in List for more natural navigation

📊 Changes

1 file changed (+41 additions, -16 deletions)

View changed files

📝 list.go (+41 -16)

📄 Description

This change adds a single new field viewOffset to the List struct because it is impossible (I'm pretty sure) to determine which items should be drawn at any given instant with only the state information available when Draw() is called.

This new viewOffset field effectively remembers where the view existed the last time Draw() was called, and from that along with the currently selected item, determines which items need to be drawn.

Please test this out, it felt very natural to me, but I haven't looked to see if Table or TreeView would also benefit from the same logic.

This resolves issue #217


🔄 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/218 **Author:** [@ardnew](https://github.com/ardnew) **Created:** 1/3/2019 **Status:** ❌ Closed **Base:** `master` ← **Head:** `list-viewtracking` --- ### 📝 Commits (1) - [`d3867f3`](https://github.com/rivo/tview/commit/d3867f3b1493e7d5c7862e314121b7d4f24ea73e) change: implemented view tracking in List for more natural navigation ### 📊 Changes **1 file changed** (+41 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `list.go` (+41 -16) </details> ### 📄 Description This change adds a single new field `viewOffset` to the `List` struct because it is impossible (I'm _pretty_ sure) to determine which items should be drawn at any given instant with only the state information available when `Draw()` is called. This new `viewOffset` field effectively remembers where the view existed the _last_ time `Draw()` was called, and from that along with the currently selected item, determines which items need to be drawn. Please test this out, it felt very natural to me, but I haven't looked to see if `Table` or `TreeView` would also benefit from the same logic. This resolves issue #217 --- <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:23 +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#882
No description provided.