mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 09:28:21 +00:00
fix missing commit in single commit repo (#75)
This commit is contained in:
parent
c17c927298
commit
7c8b7bf998
2 changed files with 15 additions and 9 deletions
|
|
@ -28,7 +28,7 @@ static SLICE_SIZE: usize = 1200;
|
|||
///
|
||||
pub struct Revlog {
|
||||
selection: usize,
|
||||
selection_max: usize,
|
||||
count_total: usize,
|
||||
items: ItemBatch,
|
||||
git_log: AsyncLog,
|
||||
visible: bool,
|
||||
|
|
@ -50,7 +50,7 @@ impl Revlog {
|
|||
items: ItemBatch::default(),
|
||||
git_log: AsyncLog::new(sender.clone()),
|
||||
selection: 0,
|
||||
selection_max: 0,
|
||||
count_total: 0,
|
||||
visible: false,
|
||||
first_open_done: false,
|
||||
scroll_state: (Instant::now(), 0_f32),
|
||||
|
|
@ -66,12 +66,16 @@ impl Revlog {
|
|||
self.git_log.is_pending()
|
||||
}
|
||||
|
||||
fn selection_max(&self) -> usize {
|
||||
self.count_total.saturating_sub(1)
|
||||
}
|
||||
|
||||
///
|
||||
pub fn update(&mut self) {
|
||||
self.selection_max =
|
||||
self.git_log.count().unwrap().saturating_sub(1);
|
||||
self.count_total = self.git_log.count().unwrap();
|
||||
|
||||
if self.items.needs_data(self.selection, self.selection_max) {
|
||||
if self.items.needs_data(self.selection, self.selection_max())
|
||||
{
|
||||
self.fetch_commits();
|
||||
}
|
||||
|
||||
|
|
@ -119,10 +123,11 @@ impl Revlog {
|
|||
self.selection.saturating_add(page_offset)
|
||||
}
|
||||
ScrollType::Home => 0,
|
||||
ScrollType::End => self.selection_max,
|
||||
ScrollType::End => self.selection_max(),
|
||||
};
|
||||
|
||||
self.selection = cmp::min(self.selection, self.selection_max);
|
||||
self.selection =
|
||||
cmp::min(self.selection, self.selection_max());
|
||||
|
||||
self.update();
|
||||
}
|
||||
|
|
@ -244,7 +249,8 @@ impl DrawableComponent for Revlog {
|
|||
|
||||
let title = format!(
|
||||
"commit {}/{}",
|
||||
self.selection, self.selection_max,
|
||||
self.count_total.saturating_sub(self.selection),
|
||||
self.count_total,
|
||||
);
|
||||
|
||||
f.render_widget(
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ impl ItemBatch {
|
|||
.min(idx_max);
|
||||
|
||||
let needs_data_top = want_min < self.index_offset;
|
||||
let needs_data_bottom = want_max > self.last_idx();
|
||||
let needs_data_bottom = want_max >= self.last_idx();
|
||||
needs_data_bottom || needs_data_top
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue