@@ -28,7 +28,7 @@ static SLICE_SIZE: usize = 1200;
28
28
///
29
29
pub struct Revlog {
30
30
selection : usize ,
31
- selection_max : usize ,
31
+ count_total : usize ,
32
32
items : ItemBatch ,
33
33
git_log : AsyncLog ,
34
34
visible : bool ,
@@ -50,7 +50,7 @@ impl Revlog {
50
50
items : ItemBatch :: default ( ) ,
51
51
git_log : AsyncLog :: new ( sender. clone ( ) ) ,
52
52
selection : 0 ,
53
- selection_max : 0 ,
53
+ count_total : 0 ,
54
54
visible : false ,
55
55
first_open_done : false ,
56
56
scroll_state : ( Instant :: now ( ) , 0_f32 ) ,
@@ -66,12 +66,16 @@ impl Revlog {
66
66
self . git_log . is_pending ( )
67
67
}
68
68
69
+ fn selection_max ( & self ) -> usize {
70
+ self . count_total . saturating_sub ( 1 )
71
+ }
72
+
69
73
///
70
74
pub fn update ( & mut self ) {
71
- self . selection_max =
72
- self . git_log . count ( ) . unwrap ( ) . saturating_sub ( 1 ) ;
75
+ self . count_total = self . git_log . count ( ) . unwrap ( ) ;
73
76
74
- if self . items . needs_data ( self . selection , self . selection_max ) {
77
+ if self . items . needs_data ( self . selection , self . selection_max ( ) )
78
+ {
75
79
self . fetch_commits ( ) ;
76
80
}
77
81
@@ -119,10 +123,11 @@ impl Revlog {
119
123
self . selection . saturating_add ( page_offset)
120
124
}
121
125
ScrollType :: Home => 0 ,
122
- ScrollType :: End => self . selection_max ,
126
+ ScrollType :: End => self . selection_max ( ) ,
123
127
} ;
124
128
125
- self . selection = cmp:: min ( self . selection , self . selection_max ) ;
129
+ self . selection =
130
+ cmp:: min ( self . selection , self . selection_max ( ) ) ;
126
131
127
132
self . update ( ) ;
128
133
}
@@ -244,7 +249,8 @@ impl DrawableComponent for Revlog {
244
249
245
250
let title = format ! (
246
251
"commit {}/{}" ,
247
- self . selection, self . selection_max,
252
+ self . count_total. saturating_sub( self . selection) ,
253
+ self . count_total,
248
254
) ;
249
255
250
256
f. render_widget (
0 commit comments