Hide block cursor text when the cursor is within a redacted range (#45549)

Rocky Shi created

Closes [#ISSUE](https://github.com/zed-industries/zed/issues/20696)

Release Notes:

- Hide block cursor text when the cursor is within a redacted range

Screenshot:

<img width="434" height="174" alt="image"
src="https://github.com/user-attachments/assets/5d9dc140-7abe-49a8-823a-58deb0e170dc"
/>

Change summary

crates/editor/src/element.rs | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

Detailed changes

crates/editor/src/element.rs 🔗

@@ -1797,6 +1797,7 @@ impl EditorElement {
         em_width: Pixels,
         em_advance: Pixels,
         autoscroll_containing_element: bool,
+        redacted_ranges: &[Range<DisplayPoint>],
         window: &mut Window,
         cx: &mut App,
     ) -> Vec<CursorLayout> {
@@ -1832,7 +1833,10 @@ impl EditorElement {
                     if block_width == Pixels::ZERO {
                         block_width = em_advance;
                     }
-                    let block_text = if let CursorShape::Block = selection.cursor_shape {
+                    let block_text = if selection.cursor_shape == CursorShape::Block
+                        && !redacted_ranges.iter().any(|range| {
+                            range.start <= cursor_position && cursor_position < range.end
+                        }) {
                         snapshot
                             .grapheme_at(cursor_position)
                             .or_else(|| {
@@ -10484,6 +10488,7 @@ impl Element for EditorElement {
                         em_width,
                         em_advance,
                         autoscroll_containing_element,
+                        &redacted_ranges,
                         window,
                         cx,
                     );