@@ -226,16 +226,40 @@ impl FileRevlogComponent {
226
226
if let Some ( git_log) = & mut self . git_log {
227
227
let table_state = self . table_state . take ( ) ;
228
228
229
- let start = table_state. selected ( ) . unwrap_or ( 0 ) ;
230
-
231
229
let commits = get_commits_info (
232
230
& self . repo_path . borrow ( ) ,
233
- & git_log. get_slice ( start , SLICE_SIZE ) ?,
231
+ & git_log. get_slice ( 0 , SLICE_SIZE ) ?,
234
232
self . current_width . get ( ) ,
235
233
) ;
236
234
237
235
if let Ok ( commits) = commits {
238
- self . items . set_items ( start, commits) ;
236
+ // 2023-04-12
237
+ //
238
+ // There is an issue with how windowing works in `self.items` and
239
+ // `self.table_state`. Because of that issue, we currently have to pass
240
+ // `0` as the first argument to `set_items`. If we did not do that, the
241
+ // offset that is kept separately in `self.items` and `self.table_state`
242
+ // would get out of sync, resulting in the table showing the wrong rows.
243
+ //
244
+ // The offset determines the number of rows `render_stateful_widget`
245
+ // skips when rendering a table. When `set_items` is called, it clears
246
+ // its internal `Vec` of items and sets `index_offset` based on the
247
+ // parameter passed. Unfortunately, there is no way for us to pass this
248
+ // information, `index_offset`, to `render_stateful_widget`. Because of
249
+ // that, `render_stateful_widget` assumes that the rows provided by
250
+ // `Table` are 0-indexed while in reality they are
251
+ // `index_offset`-indexed.
252
+ //
253
+ // This fix makes the `FileRevlog` unable to show histories that have
254
+ // more than `SLICE_SIZE` items, but since it is broken for larger
255
+ // histories anyway, this seems acceptable for the time being.
256
+ //
257
+ // This issue can only properly be fixed upstream, in `tui-rs`. See
258
+ // [tui-issue].
259
+ //
260
+ // [gitui-issue]: https://github.com/extrawurst/gitui/issues/1560
261
+ // [tui-issue]: https://github.com/fdehau/tui-rs/issues/626
262
+ self . items . set_items ( 0 , commits) ;
239
263
}
240
264
241
265
self . table_state . set ( table_state) ;
0 commit comments