feat: file and status tab support pageup and pagedown#2496
feat: file and status tab support pageup and pagedown#2496extrawurst merged 25 commits intogitui-org:masterfrom
Conversation
|
I just tested this PR and ran into the following panic in the status tab (this is not the full stacktrace, but the parts that seemed relevant): Before the test, I had prepared the directory by creating 101 empty test files using the following fish script: |
cb78b30 to
0f338b8
Compare
|
@cruessler Thanks for your comment. I reproduced it and fixed it. |
|
I’d like to suggest a change that is somewhat larger, but that would, in my opinion at least, make the code more easy to understand. The change would also make the code more re-usable, so it could be re-used for the other movement commands in a follow-up PR. In particular, you could change fn selection_page_updown(
&self,
current_index: usize,
range: impl Iterator<Item = usize>,
) -> SelectionChange {
let page_size = self.window_height.get().unwrap_or(0);
let new_index = range
.filter(|index| self.is_visible_index(*index))
.take(page_size)
.last()
.unwrap_or(current_index);
SelectionChange::new(new_index, false)
}If you did that, you would also need to adapt MoveSelection::PageUp => self.selection_page_updown(
selection,
(0..(selection + 1)).rev(),
),
MoveSelection::PageDown => self
.selection_page_updown(
selection,
selection..(self.tree.len()),
),With these two changes, the code would have fewer conditionals and control flow would be much easier to understand. What do you think? |
|
Your advice is awesome and reliable. I will use it, but I made some changes by adding the code |
|
I’m glad you liked the suggestion! If I’m not mistaken, you could make the same type of change here: https://github.com/Fatpandac/gitui/blob/0f338b8201d185f9afbea24cae9246c5f3080216/filetreelist/src/filetree.rs#L117-L158. Do you want to rename |
03c6c04 to
885c06b
Compare
cruessler
left a comment
There was a problem hiding this comment.
@extrawurst I think this is ready for the final review!
- I’ve tested both the files and the status tree, including by resizing the
gituiwindow. Page up and down behaves similarly to how it behaves in the log tab. - There are a couple of things that could be done with respect to de-duplicating code in the components that were changed in this PR, but I suggest we do that in a follow-up PR.
This Pull Request fixes #1951.
It changes the following:
I followed the checklist:
make checkwithout errors