mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 17:08:21 +00:00
Fix file history for sizes <= 1200 entries
This commit is contained in:
parent
9b09617f85
commit
49cd7ea2db
1 changed files with 28 additions and 4 deletions
|
|
@ -226,16 +226,40 @@ impl FileRevlogComponent {
|
||||||
if let Some(git_log) = &mut self.git_log {
|
if let Some(git_log) = &mut self.git_log {
|
||||||
let table_state = self.table_state.take();
|
let table_state = self.table_state.take();
|
||||||
|
|
||||||
let start = table_state.selected().unwrap_or(0);
|
|
||||||
|
|
||||||
let commits = get_commits_info(
|
let commits = get_commits_info(
|
||||||
&self.repo_path.borrow(),
|
&self.repo_path.borrow(),
|
||||||
&git_log.get_slice(start, SLICE_SIZE)?,
|
&git_log.get_slice(0, SLICE_SIZE)?,
|
||||||
self.current_width.get(),
|
self.current_width.get(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Ok(commits) = commits {
|
if let Ok(commits) = commits {
|
||||||
self.items.set_items(start, commits);
|
// 2023-04-12
|
||||||
|
//
|
||||||
|
// There is an issue with how windowing works in `self.items` and
|
||||||
|
// `self.table_state`. Because of that issue, we currently have to pass
|
||||||
|
// `0` as the first argument to `set_items`. If we did not do that, the
|
||||||
|
// offset that is kept separately in `self.items` and `self.table_state`
|
||||||
|
// would get out of sync, resulting in the table showing the wrong rows.
|
||||||
|
//
|
||||||
|
// The offset determines the number of rows `render_stateful_widget`
|
||||||
|
// skips when rendering a table. When `set_items` is called, it clears
|
||||||
|
// its internal `Vec` of items and sets `index_offset` based on the
|
||||||
|
// parameter passed. Unfortunately, there is no way for us to pass this
|
||||||
|
// information, `index_offset`, to `render_stateful_widget`. Because of
|
||||||
|
// that, `render_stateful_widget` assumes that the rows provided by
|
||||||
|
// `Table` are 0-indexed while in reality they are
|
||||||
|
// `index_offset`-indexed.
|
||||||
|
//
|
||||||
|
// This fix makes the `FileRevlog` unable to show histories that have
|
||||||
|
// more than `SLICE_SIZE` items, but since it is broken for larger
|
||||||
|
// histories anyway, this seems acceptable for the time being.
|
||||||
|
//
|
||||||
|
// This issue can only properly be fixed upstream, in `tui-rs`. See
|
||||||
|
// [tui-issue].
|
||||||
|
//
|
||||||
|
// [gitui-issue]: https://github.com/extrawurst/gitui/issues/1560
|
||||||
|
// [tui-issue]: https://github.com/fdehau/tui-rs/issues/626
|
||||||
|
self.items.set_items(0, commits);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.table_state.set(table_state);
|
self.table_state.set(table_state);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue