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

fix(scrolling): don't reset the scrolling when the window position changes #2208

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 16 additions & 8 deletions src/renderer/rendered_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
cmd_line::CmdLineSettings,
dimensions::Dimensions,
editor::{AnchorInfo, Style, WindowType},
profiling::tracy_zone,
profiling::{tracy_plot, tracy_zone},
renderer::{animation_utils::*, GridRenderer, RendererSettings},
settings::SETTINGS,
utils::RingBuffer,
Expand Down Expand Up @@ -216,10 +216,16 @@ impl RenderedWindow {
);
animating |= self.grid_current_position != prev_position;

animating |= self
let scrolling = self
.scroll_animation
.update(dt, settings.scroll_animation_length);

animating |= scrolling;

if scrolling {
tracy_plot!("Scroll position {}", self.scroll_animation.position.into());
}

animating
}

Expand Down Expand Up @@ -483,12 +489,15 @@ impl RenderedWindow {
}

let height = new_grid_size.height as usize;
self.actual_lines.resize(height, None);
self.grid_size = new_grid_size;
if height != self.actual_lines.len() {
self.actual_lines.resize(height, None);
self.grid_size = new_grid_size;

self.scrollback_lines.resize(2 * height, None);
self.scrollback_lines.clone_from_iter(&self.actual_lines);
self.scroll_delta = 0;
self.scrollback_lines.resize(2 * height, None);
self.scrollback_lines.clone_from_iter(&self.actual_lines);
self.scroll_delta = 0;
self.scroll_animation.reset();
}

self.anchor_info = anchor_info;
self.window_type = window_type;
Expand All @@ -500,7 +509,6 @@ impl RenderedWindow {
self.grid_start_position = new_destination;
self.grid_destination = new_destination;
}
self.scroll_animation.reset();
}
WindowDrawCommand::DrawLine {
row,
Expand Down