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.

Allow cursors to be shown via a command

Joseph T. Lyons0062cc000b82
diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json
index f18cc2a111e..c4cfed2916c 100644
--- a/assets/keymaps/default.json
+++ b/assets/keymaps/default.json
@@ -349,7 +349,8 @@
"alt-cmd-]": "editor::UnfoldLines",
"ctrl-space": "editor::ShowCompletions",
"cmd-.": "editor::ToggleCodeActions",
- "alt-cmd-r": "editor::RevealInFinder"
+ "alt-cmd-r": "editor::RevealInFinder",
+ "ctrl-cmd-c": "editor::ShowCursors"
}
},
{
diff --git a/crates/editor/src/actions.rs b/crates/editor/src/actions.rs
index 9532bb642d8..dd489c03939 100644
--- a/crates/editor/src/actions.rs
+++ b/crates/editor/src/actions.rs
@@ -214,5 +214,6 @@ gpui::actions!(
Undo,
UndoSelection,
UnfoldLines,
+ ShowCursors
]
);
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 8876feeceff..3b7b99cb82e 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -3899,6 +3899,24 @@ impl Editor {
self.update_visible_copilot_suggestion(cx);
}
+ pub fn show_cursors(&mut self, _: &ShowCursors, cx: &mut ViewContext<Self>) {
+ self.display_cursors(cx);
+ }
+
+ fn display_cursors(&mut self, cx: &mut ViewContext<Self>) {
+ self.recently_focused = true;
+ cx.notify();
+ cx.spawn(|this, mut cx| async move {
+ cx.background_executor().timer(Duration::from_secs(2)).await;
+ this.update(&mut cx, |this, cx| {
+ this.recently_focused = false;
+ cx.notify()
+ })
+ .ok()
+ })
+ .detach();
+ }
+
fn next_copilot_suggestion(&mut self, _: &copilot::NextSuggestion, cx: &mut ViewContext<Self>) {
if self.has_active_copilot_suggestion(cx) {
self.cycle_copilot_suggestions(Direction::Next, cx);
@@ -9003,17 +9021,7 @@ impl Editor {
cx.focus(&rename_editor_focus_handle);
} else {
self.blink_manager.update(cx, BlinkManager::enable);
- self.recently_focused = true;
- cx.notify();
- cx.spawn(|this, mut cx| async move {
- cx.background_executor().timer(Duration::from_secs(2)).await;
- this.update(&mut cx, |this, cx| {
- this.recently_focused = false;
- cx.notify()
- })
- .ok()
- })
- .detach();
+ self.display_cursors(cx);
self.buffer.update(cx, |buffer, cx| {
buffer.finalize_last_transaction(cx);
if self.leader_peer_id.is_none() {
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs
index 6c6bfba190c..2f7afe2d06e 100644
--- a/crates/editor/src/element.rs
+++ b/crates/editor/src/element.rs
@@ -327,6 +327,7 @@ impl EditorElement {
register_action(view, cx, Editor::context_menu_prev);
register_action(view, cx, Editor::context_menu_next);
register_action(view, cx, Editor::context_menu_last);
+ register_action(view, cx, Editor::show_cursors);
}
fn register_key_listeners(&self, cx: &mut WindowContext) {