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

keep track of scrollback buffer size #881

Merged

Conversation

tlinford
Copy link
Contributor

initial attempt at solving #877

missing handling of when the viewport gets switched to alternative_viewport

@tlinford tlinford requested a review from imsnif November 18, 2021 08:21
@tlinford tlinford marked this pull request as draft November 18, 2021 08:24
Copy link
Member

@imsnif imsnif left a comment

Choose a reason for hiding this comment

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

Looks like this turned out to be like a fair bit of work! Happy to see this though.
I have not tried this and only glanced over the code. Left some comments. I trust that you went through the basic smoke tests to make sure this works... only thing I can add (if you didn't try) is to make sure this doesn't slow pane resizing too much when the scrollbuffer is very full.

About alternative grid: I think we can totally ignore that use case (as long as it doesn't break the main one). Ideally scrolling should be completely disabled when the alternative grid is set (both in the UI and functionality).

zellij-server/src/panes/grid.rs Outdated Show resolved Hide resolved
@@ -170,6 +177,7 @@ fn transfer_rows_from_viewport_to_lines_above(
viewport.insert(0, row);
}
}
transferred_rows_height
Copy link
Member

Choose a reason for hiding this comment

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

We need to account for the bounded_push above somehow. There's a chance that it drops a line if it overflows the buffer... maybe also return a value from it?

@@ -557,6 +575,8 @@ impl Grid {
pub fn scroll_down_one_line(&mut self) {
if !self.lines_below.is_empty() && self.viewport.len() == self.height {
let mut line_to_push_up = self.viewport.remove(0);
self.scrollback_buffer_lines +=
(line_to_push_up.width() as f64 / self.width as f64).ceil() as usize;
if line_to_push_up.is_canonical {
bounded_push(&mut self.lines_above, line_to_push_up);
Copy link
Member

Choose a reason for hiding this comment

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

We also need to account for bounded_push here, it might drop lines

@tlinford
Copy link
Contributor Author

i should have addressed the bounded push cases.
perfomance on resize seems to be unchanged.
the alternative grid case does need handling i think, seems to be used at least by nvim :)

@imsnif
Copy link
Member

imsnif commented Nov 19, 2021

What happens right now with the alternative grid, in this current state of affairs?

@tlinford
Copy link
Contributor Author

well i noticed something like this can happen. where you keep scrolling:
nvim-scrolled

this seems to happen regardless of these changes though.

@imsnif
Copy link
Member

imsnif commented Nov 19, 2021

Yeah, this is what I meant. We should ideally not allow scrolling when in alternative grid mode. So if this change leaves things as they are, I think it's fine.

@tlinford
Copy link
Contributor Author

@imsnif I've handled a couple more edge cases, and am seeing numbers that match what we have in main.
Performance while resizing seems comparable.
I hope I haven't missed anything, let me know if you think this is good to go.

Copy link
Member

@imsnif imsnif left a comment

Choose a reason for hiding this comment

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

Great work! Thanks for doing this. This LGTM! (only thing is to remove the log messages :) )

@tlinford tlinford marked this pull request as ready for review November 22, 2021 17:08
@tlinford tlinford changed the title wip: keep track of scrollback buffer size keep track of scrollback buffer size Nov 22, 2021
@tlinford tlinford merged commit 707fedd into zellij-org:main Nov 22, 2021
@tlinford tlinford deleted the fix/877-slowdown-with-large-scrollback branch November 22, 2021 17:34
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.

2 participants