feat(core): add page up/down to tui shortcuts - #34525
Conversation
✅ Deploy Preview for nx-docs canceled.
|
✅ Deploy Preview for nx-dev canceled.
|
d99ca86 to
cdae067
Compare
leosvelperez
left a comment
There was a problem hiding this comment.
Thanks! This was something on my list, but I hadn't gotten to it.
Left some suggestions to avoid the loops and update the scroll state more directly.
| // Handle PageUp/PageDown for full-page scrolling when not in interactive mode | ||
| KeyCode::PageUp if !self.is_interactive => { | ||
| let (rows, _) = pty_mut.get_dimensions(); | ||
| let page = (rows as u8).saturating_sub(2).max(1); |
There was a problem hiding this comment.
rows is u16 (from get_dimensions()) but as u8 silently keeps only the low 8 bits. For terminals >255 rows (very unlikely, but not impossible), this would wrap unpredictably (e.g., 256 rows → page=1, 300 → page=42).
| let page = (rows as u8).saturating_sub(2).max(1); | |
| let page = (rows.min(255) as u8).saturating_sub(2).max(1); |
| } | ||
| KeyCode::PageDown if !self.is_interactive => { | ||
| let (rows, _) = pty_mut.get_dimensions(); | ||
| let page = (rows as u8).saturating_sub(2).max(1); |
There was a problem hiding this comment.
Same here:
| let page = (rows as u8).saturating_sub(2).max(1); | |
| let page = (rows.min(255) as u8).saturating_sub(2).max(1); |
| let page = viewport_height.saturating_sub(2).max(1); | ||
| for _ in 0..page { | ||
| self.scroll_up(); | ||
| } |
There was a problem hiding this comment.
The loop calls scroll_up() N times, each doing a bounds check + decrement. Could be a single operation:
| let page = viewport_height.saturating_sub(2).max(1); | |
| for _ in 0..page { | |
| self.scroll_up(); | |
| } | |
| let page = viewport_height.saturating_sub(2).max(1); | |
| self.scroll_offset = self.scroll_offset.saturating_sub(page); |
| let page = viewport_height.saturating_sub(2).max(1); | ||
| for _ in 0..page { | ||
| self.scroll_down(viewport_height); | ||
| } |
There was a problem hiding this comment.
Same thing here:
| let page = viewport_height.saturating_sub(2).max(1); | |
| for _ in 0..page { | |
| self.scroll_down(viewport_height); | |
| } | |
| let page = viewport_height.saturating_sub(2).max(1); | |
| self.scroll_offset = (self.scroll_offset + page).min(max_scroll); |
| let page = self.viewport_height.saturating_sub(2).max(1); | ||
| for _ in 0..page { | ||
| self.scroll_up(); | ||
| } |
There was a problem hiding this comment.
Same loop pattern — can be a single offset operation (scrollbar state only needs one update):
| let page = self.viewport_height.saturating_sub(2).max(1); | |
| for _ in 0..page { | |
| self.scroll_up(); | |
| } | |
| let page = self.viewport_height.saturating_sub(2).max(1); | |
| self.scroll_offset = self.scroll_offset.saturating_sub(page); | |
| self.scrollbar_state = self | |
| .scrollbar_state | |
| .content_length(self.content_height) | |
| .viewport_content_length(self.viewport_height) | |
| .position(self.scroll_offset); |
| let page = self.viewport_height.saturating_sub(2).max(1); | ||
| for _ in 0..page { | ||
| self.scroll_down(); | ||
| } |
There was a problem hiding this comment.
Same here:
| let page = self.viewport_height.saturating_sub(2).max(1); | |
| for _ in 0..page { | |
| self.scroll_down(); | |
| } | |
| let page = self.viewport_height.saturating_sub(2).max(1); | |
| let max_scroll = self.content_height.saturating_sub(self.viewport_height); | |
| self.scroll_offset = (self.scroll_offset + page).min(max_scroll); | |
| self.scrollbar_state = self | |
| .scrollbar_state | |
| .content_length(self.content_height) | |
| .viewport_content_length(self.viewport_height) | |
| .position(self.scroll_offset); |
|
View your CI Pipeline Execution ↗ for commit 6bf262a
☁️ Nx Cloud last updated this comment at |
56b16be to
6bf262a
Compare
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
Page Up/Down are not implemented as navigation keys in TUI
Expected Behavior
They are now Implemented.
Related Issue(s)
Fixes #