@@ -3537,7 +3537,10 @@ def _go_top(self):
3537
3537
3538
3538
def _go_bottom (self ):
3539
3539
self ._selection = len (self ._list ) - 1
3540
- self ._start = self ._selection - self ._number_of_lines + 1
3540
+ if len (self ._list ) <= self ._number_of_lines :
3541
+ self ._start = 0
3542
+ else :
3543
+ self ._start = self ._selection - self ._number_of_lines + 1
3541
3544
self ._needs_update = True
3542
3545
3543
3546
def _go_down (self , step = 1 ):
@@ -3591,7 +3594,10 @@ def _go_up(self, step=1):
3591
3594
logger .error (f'{ next_selection = } ' )
3592
3595
if next_selection < 0 :
3593
3596
self ._selection = len (self ._list ) - 1
3594
- self ._start = len (self ._list ) - self ._number_of_lines
3597
+ if len (self ._list ) <= self ._number_of_lines :
3598
+ self ._start = 0
3599
+ else :
3600
+ self ._start = len (self ._list ) - self ._number_of_lines
3595
3601
self ._needs_update = True
3596
3602
return
3597
3603
line = next_selection - self ._start - 2
@@ -3649,6 +3655,9 @@ def _init_win(self):
3649
3655
self ._make_selection_visible ()
3650
3656
3651
3657
def _make_selection_visible (self ):
3658
+ if len (self ._list ) <= self ._number_of_lines :
3659
+ self ._start = 0
3660
+ return
3652
3661
# Check if the current selection is already visible
3653
3662
if self ._start <= self ._selection < self ._start + self ._number_of_lines :
3654
3663
# Ensure that we use the expanded window space effectively
@@ -3692,7 +3701,6 @@ def _unselect_line(self, a_line):
3692
3701
self ._win .chgat (a_line , self ._max_length , self .maxX - self ._max_length - 2 , curses .color_pair (4 ))
3693
3702
3694
3703
def show (self , parent = None ):
3695
- logger .error ('def show()' )
3696
3704
if parent is not None :
3697
3705
self ._parent = parent
3698
3706
self ._init_win ()
0 commit comments