Skip to content

Commit 7c8b7bf

Browse files
author
Stephan Dilly
committed
fix missing commit in single commit repo (#75)
1 parent c17c927 commit 7c8b7bf

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/tabs/revlog/mod.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static SLICE_SIZE: usize = 1200;
2828
///
2929
pub struct Revlog {
3030
selection: usize,
31-
selection_max: usize,
31+
count_total: usize,
3232
items: ItemBatch,
3333
git_log: AsyncLog,
3434
visible: bool,
@@ -50,7 +50,7 @@ impl Revlog {
5050
items: ItemBatch::default(),
5151
git_log: AsyncLog::new(sender.clone()),
5252
selection: 0,
53-
selection_max: 0,
53+
count_total: 0,
5454
visible: false,
5555
first_open_done: false,
5656
scroll_state: (Instant::now(), 0_f32),
@@ -66,12 +66,16 @@ impl Revlog {
6666
self.git_log.is_pending()
6767
}
6868

69+
fn selection_max(&self) -> usize {
70+
self.count_total.saturating_sub(1)
71+
}
72+
6973
///
7074
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();
7376

74-
if self.items.needs_data(self.selection, self.selection_max) {
77+
if self.items.needs_data(self.selection, self.selection_max())
78+
{
7579
self.fetch_commits();
7680
}
7781

@@ -119,10 +123,11 @@ impl Revlog {
119123
self.selection.saturating_add(page_offset)
120124
}
121125
ScrollType::Home => 0,
122-
ScrollType::End => self.selection_max,
126+
ScrollType::End => self.selection_max(),
123127
};
124128

125-
self.selection = cmp::min(self.selection, self.selection_max);
129+
self.selection =
130+
cmp::min(self.selection, self.selection_max());
126131

127132
self.update();
128133
}
@@ -244,7 +249,8 @@ impl DrawableComponent for Revlog {
244249

245250
let title = format!(
246251
"commit {}/{}",
247-
self.selection, self.selection_max,
252+
self.count_total.saturating_sub(self.selection),
253+
self.count_total,
248254
);
249255

250256
f.render_widget(

src/tabs/revlog/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl ItemBatch {
5757
.min(idx_max);
5858

5959
let needs_data_top = want_min < self.index_offset;
60-
let needs_data_bottom = want_max > self.last_idx();
60+
let needs_data_bottom = want_max >= self.last_idx();
6161
needs_data_bottom || needs_data_top
6262
}
6363
}

0 commit comments

Comments
 (0)