Skip to content

Fix file history for sizes <= 1200 entries #1648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2023

Conversation

cruessler
Copy link
Collaborator

This Pull Request partly fixes #1560.

There is a lot of context in the comment I included in the change. As far as I can tell, this fix works for histories that have <= 1200 entries. If we want a solution that addresses the issue for larger histories as well, we can hopefully take this PR as a starting point. For the time being, I thought it would be best to open the PR in this state already, so we have more context and can start a discussion.

It changes the following:

  • It brings self.items.index_offset always in sync with self.table_state by always using 0 as the items’ offset

I followed the checklist:

  • I added unittests
  • I ran make check without errors
  • I tested the overall application
  • I added an appropriate item to the changelog

@extrawurst
Copy link
Collaborator

so this is still broken for files with history items >1200?

@cruessler
Copy link
Collaborator Author

Yes, the file history’s entries are loaded here: https://github.com/cruessler/gitui/blob/e40e095993dc2c7c652296a38cdb9ba2b487b7f4/src/components/file_revlog.rs#L231. The code reads &git_log.get_slice(0, SLICE_SIZE)?, so this will always load the first 1200 items, never items beyond that limit.

What we could also do is maybe introduce padding in get_rows, i. e. we could prepend the correct number of empty rows so that the offset used by render_stateful_widget would be valid. Downside: added complexity and a few bytes of additional memory used.

@extrawurst
Copy link
Collaborator

extrawurst commented Apr 19, 2023

puh i am having trouble figuring this PR out. reading the code it clearly was intended to be able to load history in batches of SLICE_SIZE.

I think we should make that work properly instead of hardcoding 0..SLICE_SIZE and calling it a day. this will effectively also remove code that was trying to make this a dynamic solution already.

making the batch size smaller (maybe even dynamic depending on terminal size and visible rows) has its merits and would allow fetching more data as needed and improving UX here too

@cruessler
Copy link
Collaborator Author

Since I wrote the initial code in file_revlog.rs, I can add a bit of context. :-) I copied the batching from revlog.rs, but I decided to use tui’s Table for rendering instead of CommitList (the latter is what Revlog uses). At that time, I was not aware that this would cause issues with batching.

From what I can tell, ratatui/ratatui#12 would resolve the issue because it would give us access to self.table_state’s offset property which we need to adjust, but currently can’t.

@extrawurst
Copy link
Collaborator

Ok I will merge this then. Let’s create a followup ticket to not forget about this Limitation and link it to the above ratatui issue 💪

@extrawurst extrawurst merged commit 49cd7ea into gitui-org:master May 4, 2023
@cruessler cruessler mentioned this pull request Jun 28, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wrong file history view
2 participants