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.

repl: Fix cursor visibility on last line after re-running cells (#48218)

MostlyK14621b66b8c2
diff --git a/crates/repl/src/session.rs b/crates/repl/src/session.rs
index 49da9d0e312..2fda4f1bede 100644
--- a/crates/repl/src/session.rs
+++ b/crates/repl/src/session.rs
@@ -95,9 +95,14 @@ impl EditorBlock {
});
}
- let invalidation_anchor = buffer.read(cx).read(cx).anchor_before(next_row_start);
+ // Re-read snapshot after potential buffer edit and create a fresh anchor for
+ // block placement. Using anchor_before (Bias::Left) ensures the anchor stays
+ // at the end of the code line regardless of whether we inserted a newline.
+ let buffer_snapshot = buffer.read(cx).snapshot(cx);
+ let block_placement_anchor = buffer_snapshot.anchor_before(end_point);
+ let invalidation_anchor = buffer_snapshot.anchor_before(next_row_start);
let block = BlockProperties {
- placement: BlockPlacement::Below(code_range.end),
+ placement: BlockPlacement::Below(block_placement_anchor),
// Take up at least one height for status, allow the editor to determine the real height based on the content from render
height: Some(1),
style: BlockStyle::Sticky,