A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
perf(term): walk scroll-region rows with range_mut when marking them
RoversXb6c3d203445b
diff --git a/term/src/screen.rs b/term/src/screen.rsindex 2431daea..91f6590b 100644--- a/term/src/screen.rs+++ b/term/src/screen.rs@@ -767,8 +767,10 @@ impl Screen {// of the screen based scrolling, the StableRowIndex does not change,// so we use the scroll region bounds to gate the invalidation.if !scrollback_ok {- for y in phys_scroll.clone() {- self.line_mut(y).update_last_change_seqno(seqno);+ // Walk the deque's slices: indexing each row re-derives its slot+ // from the deque header, which dominated region scrolling.+ for line in self.lines.range_mut(phys_scroll.clone()) {+ line.update_last_change_seqno(seqno);}}@@ -864,8 +866,10 @@ impl Screen {// If we have invalidated the StableRowIndex, mark all subsequent lines as dirtyif to_remove > 0 || (to_add > 0 && !insert_at_end) {- for y in self.phys_range(&(scroll_region.end..self.physical_rows as VisibleRowIndex)) {- self.line_mut(y).update_last_change_seqno(seqno);+ let below =+ self.phys_range(&(scroll_region.end..self.physical_rows as VisibleRowIndex));+ for line in self.lines.range_mut(below) {+ line.update_last_change_seqno(seqno);}}}@@ -908,8 +912,8 @@ impl Screen {let middle = phys_scroll.end - num_rows;// dirty the rows in the region- for y in phys_scroll.start..middle {- self.line_mut(y).update_last_change_seqno(seqno);+ for line in self.lines.range_mut(phys_scroll.start..middle) {+ line.update_last_change_seqno(seqno);}for _ in 0..num_rows {diff --git a/term/src/test/mod.rs b/term/src/test/mod.rsindex 4cb6e7e6..6361eee1 100644--- a/term/src/test/mod.rs+++ b/term/src/test/mod.rs@@ -1420,6 +1420,36 @@ fn test_alt_screen_region_scroll() {assert_eq!(term.screen().visible_row_to_stable_row(0), 1);}+#[test]+fn region_scrolls_mark_the_region_wherever_the_row_ring_wraps() {+ // Each pass rotates the row deque one more step, so the scroll region+ // lands on every position relative to where its storage wraps around.+ for alt in [false, true] {+ let mut term = TestTerm::new(5, 4, 3);+ if alt {+ term.set_mode("?1049", true);+ }+ for pass in 0..24 {+ term.set_scroll_region(0, 4);+ term.cup(0, 4);+ term.print(&format!("\n{}", pass));+ let top = term.screen().scrollback_rows() - 5;+ let region = [top + 1, top + 2, top + 3];++ term.set_scroll_region(1, 3);+ term.cup(0, 3);+ let seqno = term.current_seqno();+ term.print("\n");+ term.assert_dirty_lines(seqno, ®ion, Some("scroll up"));++ term.cup(0, 1);+ let seqno = term.current_seqno();+ term.print("\x1bM");+ term.assert_dirty_lines(seqno, ®ion, Some("scroll down"));+ }+ }+}+#[test]fn test_region_scrollback_limit() {// Ensure scrollback is truncated properly, when it reaches the line limit