[PR #480] [CLOSED] Fix bug in list RemoveItem #963

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

📋 Pull Request Information

Original PR: https://github.com/rivo/tview/pull/480
Author: @zmnpl
Created: 7/26/2020
Status: Closed

Base: masterHead: list-bugfix


📝 Commits (1)

📊 Changes

1 file changed (+2 additions, -2 deletions)

View changed files

📝 list.go (+2 -2)

📄 Description

When a changed function is set, deleting the first element (0-index) lead to a index out of range error because the change event was fired with index = -1.
Now the index will only be decreased if the last item was removed. As a side effect that changes the behavior of the selection slightly:
It will stay at the same place and only move up when the last item was removed.


🔄 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/480 **Author:** [@zmnpl](https://github.com/zmnpl) **Created:** 7/26/2020 **Status:** ❌ Closed **Base:** `master` ← **Head:** `list-bugfix` --- ### 📝 Commits (1) - [`3947f78`](https://github.com/rivo/tview/commit/3947f78c563857cc9899e84e47f1026aba12f979) Fix but in list ### 📊 Changes **1 file changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `list.go` (+2 -2) </details> ### 📄 Description When a changed function is set, deleting the first element (0-index) lead to a index out of range error because the change event was fired with index = -1. Now the index will only be decreased if the last item was removed. As a side effect that changes the behavior of the selection slightly: It will stay at the same place and only move up when the last item was removed. --- <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:46 +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#963
No description provided.