Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

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

Rocky Shif21a357f7637
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs
index 471af3741b9..dc37965779c 100644
--- a/crates/editor/src/element.rs
+++ b/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,
);