Skip to content

Commit

Permalink
fix(multiuser): properly clear fake cursors (#3845)
Browse files Browse the repository at this point in the history
  • Loading branch information
imsnif authored Dec 6, 2024
1 parent 213a9e0 commit 9332714
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions zellij-server/src/panes/terminal_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,20 @@ impl Pane for TerminalPane {
self.style.rounded_corners = rounded_corners;
self.frame.clear();
}
fn drain_fake_cursors(&mut self) -> Option<HashSet<(usize, usize)>> {
if !self.fake_cursor_locations.is_empty() {
for (y, _x) in &self.fake_cursor_locations {
// we do this because once these fake_cursor_locations
// have been drained, we have to make sure to render the line
// they appeared on so that whatever clears their location
// won't leave a hole
self.grid.update_line_for_rendering(*y);
}
Some(self.fake_cursor_locations.drain().collect())
} else {
None
}
}
}

impl TerminalPane {
Expand Down
3 changes: 3 additions & 0 deletions zellij-server/src/tab/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,9 @@ pub trait Pane {
fn query_should_be_suppressed(&self) -> bool {
false
}
fn drain_fake_cursors(&mut self) -> Option<HashSet<(usize, usize)>> {
None
}
}

#[derive(Clone, Debug)]
Expand Down
4 changes: 4 additions & 0 deletions zellij-server/src/ui/pane_contents_and_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ impl<'a> PaneContentsAndUi<'a> {
) -> Result<()> {
let err_context = "failed to render pane contents to multiple clients";

// here we drop the fake cursors so that their lines will be updated
// and we can clear them from the UI below
drop(self.pane.drain_fake_cursors());

if let Some((character_chunks, raw_vte_output, sixel_image_chunks)) =
self.pane.render(None).context(err_context)?
{
Expand Down

0 comments on commit 9332714

Please sign in to comment.