Skip to content
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

TUI: Follow output when scrolled to the bottom #210

Merged

Conversation

9999years
Copy link
Member

@9999years 9999years commented Mar 1, 2024

Fixes #209.

Copy link

linear bot commented Mar 1, 2024

@github-actions github-actions bot added the patch Bug fixes or non-functional changes label Mar 1, 2024
@9999years 9999years force-pushed the rebeccat/dux-1987-tui-follow-output-when-scrolled-to-bottom branch from 129760d to 92fd614 Compare March 1, 2024 18:40
@9999years 9999years requested a review from evanrelf March 1, 2024 18:40
@9999years 9999years marked this pull request as ready for review March 1, 2024 18:40
@9999years 9999years force-pushed the rebeccat/dux-1987-tui-follow-output-when-scrolled-to-bottom branch from 92fd614 to 5d63561 Compare March 1, 2024 18:44
src/tui/mod.rs Outdated
@@ -122,10 +122,18 @@ impl Tui {
self.scroll_offset = min(self.scroll_max(), scroll_offset);
}

fn maybe_follow(&mut self) {
let height = self.size.height as usize;
if self.scroll_offset >= self.line_count - height - 1 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit pick: I would add parens to make order of operations more obvious.

Suggested change
if self.scroll_offset >= self.line_count - height - 1 {
if self.scroll_offset >= self.line_count - (height + 1) {

src/tui/mod.rs Outdated Show resolved Hide resolved
src/tui/mod.rs Show resolved Hide resolved
@9999years 9999years merged commit 521c121 into main Mar 2, 2024
28 checks passed
@9999years 9999years deleted the rebeccat/dux-1987-tui-follow-output-when-scrolled-to-bottom branch March 2, 2024 00:25
}

impl Default for TuiState {
fn default() -> Self {
Self {
quit: false,
scrollback: Vec::with_capacity(TUI_SCROLLBACK_CAPACITY),
line_count: 1,
scroll_offset: 0,
line_count: Saturating(1),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol you could go even further and make this a NonZeroUsize

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Bug fixes or non-functional changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DUX-1987] TUI: Follow output when scrolled to bottom
2 participants