Skip to content

Commit 4f01ef7

Browse files
author
Stephan Dilly
committed
fix log not being updated after commit
1 parent 2028643 commit 4f01ef7

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/tabs/revlog/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ impl Revlog {
213213
let mut txt = Vec::new();
214214

215215
for (idx, e) in self
216-
.items
217216
.items
218217
.iter()
219218
.skip(self.scroll_top)
@@ -238,7 +237,7 @@ impl Revlog {
238237
}
239238

240239
fn relative_selection(&self) -> usize {
241-
self.selection.saturating_sub(self.items.index_offset)
240+
self.selection.saturating_sub(self.items.index_offset())
242241
}
243242
}
244243

@@ -346,6 +345,7 @@ impl Component for Revlog {
346345

347346
fn show(&mut self) {
348347
self.visible = true;
349-
self.git_log.fetch().unwrap();
348+
self.items.clear();
349+
self.update();
350350
}
351351
}

src/tabs/revlog/utils.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use asyncgit::sync::CommitInfo;
22
use chrono::prelude::*;
3+
use std::slice::Iter;
34

45
static SLICE_OFFSET_RELOAD_THRESHOLD: usize = 100;
56

@@ -30,15 +31,31 @@ impl From<CommitInfo> for LogEntry {
3031
///
3132
#[derive(Default)]
3233
pub(super) struct ItemBatch {
33-
pub index_offset: usize,
34-
pub items: Vec<LogEntry>,
34+
index_offset: usize,
35+
items: Vec<LogEntry>,
3536
}
3637

3738
impl ItemBatch {
3839
fn last_idx(&self) -> usize {
3940
self.index_offset + self.items.len()
4041
}
4142

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
4259
pub fn set_items(
4360
&mut self,
4461
start_index: usize,
@@ -49,6 +66,7 @@ impl ItemBatch {
4966
self.index_offset = start_index;
5067
}
5168

69+
/// returns `true` if we should fetch updated list of items
5270
pub fn needs_data(&self, idx: usize, idx_max: usize) -> bool {
5371
let want_min =
5472
idx.saturating_sub(SLICE_OFFSET_RELOAD_THRESHOLD);

0 commit comments

Comments
 (0)