a7ce677ac3835c0f78ef8ca8f458565dddb49daf
This brings the terminal element's viewport culling in line with the editor optimization in PR #44995 and the fix in PR #45077. ## Problem When a terminal is inside a scrollable container (e.g., the Agent Panel thread view), it would render ALL cells during prepaint, even when the terminal was entirely outside the viewport. This caused unnecessary CPU usage when multiple terminal tool outputs existed in the Agent Panel. ## Solution Calculate the intersection of the terminal's bounds with the current content_mask (the visible viewport after all parent clipping). If the intersection has zero area, skip all cell processing entirely. ### Three code paths 1. **Offscreen** (`intersection.size <= 0`): Early exit, process 0 cells 2. **Fully visible** (`intersection == bounds`): Fast path, stream cells directly (no allocation) 3. **Partially clipped**: Group cells by line, skip/take visible rows only ### Key insight: filter by screen position, not buffer coordinates The previous approach tried to filter cells by `cell.point.line` (terminal buffer coordinates), which breaks in Scrollable mode where cells can have negative line numbers for scrollback history. The new approach filters by **screen position** using `chunk_by(line).skip(N).take(M)`, which works regardless of the actual line numbers because we're filtering on enumerated line group index. ## Testing Added comprehensive unit tests for: - Screen-position filtering with positive lines (Inline mode) - Screen-position filtering with negative lines (Scrollable mode with scrollback) - Edge cases (skip all, positioning math) - Unified filtering works for both modes Manually verified: - Terminal fully visible (no clipping) ✓ - Terminal clipped from top/bottom ✓ - Terminal completely outside viewport ✓ - Scrollable terminals with scrollback history ✓ - Selection/interaction still works ✓ Release Notes: - Improved Agent Panel performance when terminals are scrolled offscreen. /cc @as-cii
Zed
Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Installation
On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).
Other platforms are not yet available:
- Web (tracking issue)
Developing Zed
Contributing
See CONTRIBUTING.md for ways you can contribute to Zed.
Also... we're hiring! Check out our jobs page for open roles.
Licensing
License information for third party dependencies must be correctly provided for CI to pass.
We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:
- Is it showing a
no license specifiederror for a crate you've created? If so, addpublish = falseunder[package]in your crate's Cargo.toml. - Is the error
failed to satisfy license requirementsfor a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to theacceptedarray inscript/licenses/zed-licenses.toml. - Is
cargo-aboutunable to find the license for a dependency? If so, add a clarification field at the end ofscript/licenses/zed-licenses.toml, as specified in the cargo-about book.
Description
Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Readme
586 MiB
Languages
Rust
94.7%
JSON-with-Comments
3.1%
Inno Setup
0.6%
Scheme
0.5%
Shell
0.3%
Other
0.4%