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(grid): memory leak with unfocused tabs #2745

Merged
merged 3 commits into from
Aug 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions zellij-server/src/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -829,14 +829,14 @@ impl CharacterChunk {

#[derive(Clone, Debug)]
pub struct OutputBuffer {
pub changed_lines: Vec<usize>, // line index
pub changed_lines: HashSet<usize>, // line index
pub should_update_all_lines: bool,
}

impl Default for OutputBuffer {
fn default() -> Self {
OutputBuffer {
changed_lines: vec![],
changed_lines: HashSet::new(),
should_update_all_lines: true, // first time we should do a full render
}
}
Expand All @@ -845,14 +845,14 @@ impl Default for OutputBuffer {
impl OutputBuffer {
pub fn update_line(&mut self, line_index: usize) {
if !self.should_update_all_lines {
self.changed_lines.push(line_index);
self.changed_lines.insert(line_index);
}
}
pub fn update_lines(&mut self, start: usize, end: usize) {
if !self.should_update_all_lines {
for idx in start..=end {
if !self.changed_lines.contains(&idx) {
self.changed_lines.push(idx);
self.changed_lines.insert(idx);
}
}
}
Expand Down Expand Up @@ -885,9 +885,8 @@ impl OutputBuffer {
}
changed_chunks
} else {
let mut line_changes = self.changed_lines.to_vec();
let mut line_changes: Vec<_> = self.changed_lines.iter().copied().collect();
line_changes.sort_unstable();
line_changes.dedup();
let mut changed_chunks = Vec::new();
for line_index in line_changes {
let terminal_characters =
Expand Down