Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
editor: Don't render editor behind sticky scroll header (#54465)
Cameron Mcloughlin8f0efe9f34d5
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rsindex 4162bc9c99d..3c01c12b42c 100644--- a/crates/editor/src/element.rs+++ b/crates/editor/src/element.rs@@ -11127,33 +11127,58 @@ impl Element for EditorElement {window.with_text_style(Some(text_style), |window| {window.with_content_mask(Some(ContentMask { bounds }), |window| {self.paint_mouse_listeners(layout, window, cx);- self.paint_background(layout, window, cx);- self.paint_indent_guides(layout, window, cx);+ // Mask the editor behind sticky scroll headers. Important+ // for transparent backgrounds.+ let below_sticky_headers_mask = layout+ .sticky_headers+ .as_ref()+ .and_then(|h| h.lines.last())+ .map(|last| ContentMask {+ bounds: Bounds {+ origin: point(+ bounds.origin.x,+ bounds.origin.y + last.offset + layout.position_map.line_height,+ ),+ size: size(+ bounds.size.width,+ (bounds.size.height+ - last.offset+ - layout.position_map.line_height)+ .max(Pixels::ZERO),+ ),+ },+ });- if layout.gutter_hitbox.size.width > Pixels::ZERO {- self.paint_blamed_display_rows(layout, window, cx);- self.paint_line_numbers(layout, window, cx);- }+ window.with_content_mask(below_sticky_headers_mask, |window| {+ self.paint_background(layout, window, cx);- self.paint_text(layout, window, cx);+ self.paint_indent_guides(layout, window, cx);- if !layout.spacer_blocks.is_empty() {- window.with_element_namespace("blocks", |window| {- self.paint_spacer_blocks(layout, window, cx);- });- }+ if layout.gutter_hitbox.size.width > Pixels::ZERO {+ self.paint_blamed_display_rows(layout, window, cx);+ self.paint_line_numbers(layout, window, cx);+ }- if layout.gutter_hitbox.size.width > Pixels::ZERO {- self.paint_gutter_highlights(layout, window, cx);- self.paint_gutter_indicators(layout, window, cx);- }+ self.paint_text(layout, window, cx);- if !layout.blocks.is_empty() {- window.with_element_namespace("blocks", |window| {- self.paint_non_spacer_blocks(layout, window, cx);- });- }+ if !layout.spacer_blocks.is_empty() {+ window.with_element_namespace("blocks", |window| {+ self.paint_spacer_blocks(layout, window, cx);+ });+ }++ if layout.gutter_hitbox.size.width > Pixels::ZERO {+ self.paint_gutter_highlights(layout, window, cx);+ self.paint_gutter_indicators(layout, window, cx);+ }++ if !layout.blocks.is_empty() {+ window.with_element_namespace("blocks", |window| {+ self.paint_non_spacer_blocks(layout, window, cx);+ });+ }+ });window.with_element_namespace("blocks", |window| {if let Some(mut sticky_header) = layout.sticky_buffer_header.take() {