mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 08:58:21 +00:00
fix log not being updated after commit
This commit is contained in:
parent
202864381d
commit
4f01ef783c
2 changed files with 23 additions and 5 deletions
|
|
@ -213,7 +213,6 @@ impl Revlog {
|
|||
let mut txt = Vec::new();
|
||||
|
||||
for (idx, e) in self
|
||||
.items
|
||||
.items
|
||||
.iter()
|
||||
.skip(self.scroll_top)
|
||||
|
|
@ -238,7 +237,7 @@ impl Revlog {
|
|||
}
|
||||
|
||||
fn relative_selection(&self) -> usize {
|
||||
self.selection.saturating_sub(self.items.index_offset)
|
||||
self.selection.saturating_sub(self.items.index_offset())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -346,6 +345,7 @@ impl Component for Revlog {
|
|||
|
||||
fn show(&mut self) {
|
||||
self.visible = true;
|
||||
self.git_log.fetch().unwrap();
|
||||
self.items.clear();
|
||||
self.update();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use asyncgit::sync::CommitInfo;
|
||||
use chrono::prelude::*;
|
||||
use std::slice::Iter;
|
||||
|
||||
static SLICE_OFFSET_RELOAD_THRESHOLD: usize = 100;
|
||||
|
||||
|
|
@ -30,8 +31,8 @@ impl From<CommitInfo> for LogEntry {
|
|||
///
|
||||
#[derive(Default)]
|
||||
pub(super) struct ItemBatch {
|
||||
pub index_offset: usize,
|
||||
pub items: Vec<LogEntry>,
|
||||
index_offset: usize,
|
||||
items: Vec<LogEntry>,
|
||||
}
|
||||
|
||||
impl ItemBatch {
|
||||
|
|
@ -39,6 +40,22 @@ impl ItemBatch {
|
|||
self.index_offset + self.items.len()
|
||||
}
|
||||
|
||||
///
|
||||
pub fn index_offset(&self) -> usize {
|
||||
self.index_offset
|
||||
}
|
||||
|
||||
/// shortcut to get an `Iter` of our internal items
|
||||
pub fn iter(&self) -> Iter<'_, LogEntry> {
|
||||
self.items.iter()
|
||||
}
|
||||
|
||||
/// clear curent list of items
|
||||
pub fn clear(&mut self) {
|
||||
self.items.clear();
|
||||
}
|
||||
|
||||
/// insert new batch of items
|
||||
pub fn set_items(
|
||||
&mut self,
|
||||
start_index: usize,
|
||||
|
|
@ -49,6 +66,7 @@ impl ItemBatch {
|
|||
self.index_offset = start_index;
|
||||
}
|
||||
|
||||
/// returns `true` if we should fetch updated list of items
|
||||
pub fn needs_data(&self, idx: usize, idx_max: usize) -> bool {
|
||||
let want_min =
|
||||
idx.saturating_sub(SLICE_OFFSET_RELOAD_THRESHOLD);
|
||||
|
|
|
|||
Loading…
Reference in a new issue