File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -213,7 +213,6 @@ impl Revlog {
213
213
let mut txt = Vec :: new ( ) ;
214
214
215
215
for ( idx, e) in self
216
- . items
217
216
. items
218
217
. iter ( )
219
218
. skip ( self . scroll_top )
@@ -238,7 +237,7 @@ impl Revlog {
238
237
}
239
238
240
239
fn relative_selection ( & self ) -> usize {
241
- self . selection . saturating_sub ( self . items . index_offset )
240
+ self . selection . saturating_sub ( self . items . index_offset ( ) )
242
241
}
243
242
}
244
243
@@ -346,6 +345,7 @@ impl Component for Revlog {
346
345
347
346
fn show ( & mut self ) {
348
347
self . visible = true ;
349
- self . git_log . fetch ( ) . unwrap ( ) ;
348
+ self . items . clear ( ) ;
349
+ self . update ( ) ;
350
350
}
351
351
}
Original file line number Diff line number Diff line change 1
1
use asyncgit:: sync:: CommitInfo ;
2
2
use chrono:: prelude:: * ;
3
+ use std:: slice:: Iter ;
3
4
4
5
static SLICE_OFFSET_RELOAD_THRESHOLD : usize = 100 ;
5
6
@@ -30,15 +31,31 @@ impl From<CommitInfo> for LogEntry {
30
31
///
31
32
#[ derive( Default ) ]
32
33
pub ( super ) struct ItemBatch {
33
- pub index_offset : usize ,
34
- pub items : Vec < LogEntry > ,
34
+ index_offset : usize ,
35
+ items : Vec < LogEntry > ,
35
36
}
36
37
37
38
impl ItemBatch {
38
39
fn last_idx ( & self ) -> usize {
39
40
self . index_offset + self . items . len ( )
40
41
}
41
42
43
+ ///
44
+ pub fn index_offset ( & self ) -> usize {
45
+ self . index_offset
46
+ }
47
+
48
+ /// shortcut to get an `Iter` of our internal items
49
+ pub fn iter ( & self ) -> Iter < ' _ , LogEntry > {
50
+ self . items . iter ( )
51
+ }
52
+
53
+ /// clear curent list of items
54
+ pub fn clear ( & mut self ) {
55
+ self . items . clear ( ) ;
56
+ }
57
+
58
+ /// insert new batch of items
42
59
pub fn set_items (
43
60
& mut self ,
44
61
start_index : usize ,
@@ -49,6 +66,7 @@ impl ItemBatch {
49
66
self . index_offset = start_index;
50
67
}
51
68
69
+ /// returns `true` if we should fetch updated list of items
52
70
pub fn needs_data ( & self , idx : usize , idx_max : usize ) -> bool {
53
71
let want_min =
54
72
idx. saturating_sub ( SLICE_OFFSET_RELOAD_THRESHOLD ) ;
You can’t perform that action at this time.
0 commit comments