on main help sign in
chore: small fix
commite18a77f5df5dc99ff5f5677d4281733e1f90ade5 authorKujtim Hoxha <kujtimii.h@gmail.com> dateFri 25 Jul 2025, 15:58 (1 year ago) parent0770b12
3 files changed+15−26
internal/tui/exp/list/list.go+3−14 internal/tui/exp/list/testdata/TestListMovement/should_not_change_offset_when_new_items_are_appended_and_we_are_at_the_bottom_in_backwards_list.golden+10−10 internal/tui/exp/list/testdata/TestListMovement/should_not_change_offset_when_new_items_are_prepended_and_we_are_at_the_top_in_forward_list.golden+2−2
internal/tui/exp/list/list.go+3−14
@@ -746,20 +746,16 @@ func (l *list[T]) GetSize() (int, int) {
746746
747747// GoToBottom implements List.
748748func (l *list[T]) GoToBottom() tea.Cmd {
749− if l.offset != 0 {
750− l.selectedItem = ""
751− }
752749 l.offset = 0
750+ l.selectedItem = ""
753751 l.direction = DirectionBackward
754752 return l.render()
755753}
756754
757755// GoToTop implements List.
758756func (l *list[T]) GoToTop() tea.Cmd {
759− if l.offset != 0 {
760− l.selectedItem = ""
761− }
762757 l.offset = 0
758+ l.selectedItem = ""
763759 l.direction = DirectionForward
764760 return l.render()
765761}
@@ -996,14 +992,7 @@ func (l *list[T]) UpdateItem(id string, item T) tea.Cmd {
996992 if hasOldItem && l.direction == DirectionBackward {
997993 // if we are the last item and there is no offset
998994 // make sure to go to the bottom
999− if inx == l.items.Len()-1 && l.offset == 0 {
1000− cmd = l.GoToBottom()
1001− if cmd != nil {
1002− cmds = append(cmds, cmd)
1003− }
1004−
1005− // if the item is at least partially below the viewport
1006− } else if oldPosition < oldItem.end {
995+ if oldPosition < oldItem.end {
1007996 newItem, ok := l.renderedItems.Get(item.ID())
1008997 if ok {
1009998 newLines := newItem.height - oldItem.height
internal/tui/exp/list/testdata/TestListMovement/should_not_change_offset_when_new_items_are_appended_and_we_are_at_the_bottom_in_backwards_list.golden+10−10
@@ -1,10 +1,10 @@
1−│Item 29
2−│Item 29
3−│Item 29
4−│Item 29
5−│Item 29
6−│Item 29
7−│Item 29
8−│Item 29
9−│Item 29
10−Testing 
1+Item 29
2+Item 29
3+Item 29
4+Item 29
5+Item 29
6+Item 29
7+Item 29
8+Item 29
9+Item 29
10+│Testing 
internal/tui/exp/list/testdata/TestListMovement/should_not_change_offset_when_new_items_are_prepended_and_we_are_at_the_top_in_forward_list.golden+2−2
@@ -1,5 +1,5 @@
1−Testing 
2−│Item 0
1+│Testing 
2+Item 0
33Item 1
44Item 1
55Item 2