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.

Fix cursor movement in protected files on backspace/delete (#36753)

Sarah Price54df43e06f53
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 2af8e6c0e4d..216aa2463bd 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -9809,6 +9809,9 @@ impl Editor {
}
pub fn backspace(&mut self, _: &Backspace, window: &mut Window, cx: &mut Context<Self>) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
self.transact(window, cx, |this, window, cx| {
this.select_autoclose_pair(window, cx);
@@ -9902,6 +9905,9 @@ impl Editor {
}
pub fn delete(&mut self, _: &Delete, window: &mut Window, cx: &mut Context<Self>) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
self.transact(window, cx, |this, window, cx| {
this.change_selections(Default::default(), window, cx, |s| {