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.

Exit early on mutating actions in readonly editor (#54758)

Kirill Bulatov872faf0a7bb2
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index d87729db868..7d425fa98f4 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -6682,6 +6682,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Task<Result<()>>> {
+ if self.read_only(cx) {
+ return None;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
self.do_completion(action.item_ix, CompletionIntent::Complete, window, cx)
}
@@ -6692,6 +6695,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Task<Result<()>>> {
+ if self.read_only(cx) {
+ return None;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
self.do_completion(None, CompletionIntent::CompleteWithInsert, window, cx)
}
@@ -6702,6 +6708,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Task<Result<()>>> {
+ if self.read_only(cx) {
+ return None;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
self.do_completion(None, CompletionIntent::CompleteWithReplace, window, cx)
}
@@ -7196,6 +7205,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Task<Result<()>>> {
+ if self.read_only(cx) {
+ return None;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let actions_menu =
@@ -8375,6 +8387,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
+ if self.read_only(cx) {
+ return;
+ }
if self.show_edit_predictions_in_menu() {
self.hide_context_menu(window, cx);
}
@@ -11725,6 +11740,9 @@ impl Editor {
}
pub fn delete_line(&mut self, _: &DeleteLine, window: &mut Window, cx: &mut Context<Self>) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
let selections = self.selections.all::<Point>(&display_map);
@@ -12018,6 +12036,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let snapshot = self.buffer.read(cx).snapshot(cx);
@@ -12118,6 +12139,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let mut buffer_ids = HashSet::default();
let snapshot = self.buffer().read(cx).snapshot(cx);
@@ -12137,6 +12161,9 @@ impl Editor {
}
pub fn git_restore(&mut self, _: &Restore, window: &mut Window, cx: &mut Context<Self>) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let selections = self
.selections
@@ -12156,6 +12183,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
+ if self.read_only(cx) {
+ return;
+ }
let selections = self
.selections
.all(&self.display_snapshot(cx))
@@ -12563,6 +12593,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let display_snapshot = self.display_snapshot(cx);
@@ -12801,6 +12834,9 @@ impl Editor {
}
fn rotate_selections(&mut self, window: &mut Window, cx: &mut Context<Self>, reverse: bool) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let display_snapshot = self.display_snapshot(cx);
let selections = self.selections.all::<MultiBufferOffset>(&display_snapshot);
@@ -12952,6 +12988,9 @@ impl Editor {
) where
M: FnMut(&str) -> LineManipulationResult,
{
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
@@ -13371,6 +13410,10 @@ impl Editor {
where
Fn: FnMut(&str) -> String,
{
+ if self.read_only(cx) {
+ return;
+ }
+ self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let buffer = self.buffer.read(cx).snapshot(cx);
let mut new_selections = Vec::new();
@@ -13467,6 +13510,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
@@ -13612,6 +13658,9 @@ impl Editor {
}
pub fn move_line_up(&mut self, _: &MoveLineUp, window: &mut Window, cx: &mut Context<Self>) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
if self.mode.is_single_line() {
cx.propagate();
@@ -13723,6 +13772,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
if self.mode.is_single_line() {
cx.propagate();
@@ -13817,6 +13869,9 @@ impl Editor {
}
pub fn transpose(&mut self, _: &Transpose, window: &mut Window, cx: &mut Context<Self>) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let text_layout_details = &self.text_layout_details(window, cx);
self.transact(window, cx, |this, window, cx| {
@@ -13879,6 +13934,9 @@ impl Editor {
}
pub fn rewrap(&mut self, _: &Rewrap, _: &mut Window, cx: &mut Context<Self>) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
if self.mode.is_single_line() {
cx.propagate();
@@ -13889,6 +13947,9 @@ impl Editor {
}
pub fn rewrap_impl(&mut self, options: RewrapOptions, cx: &mut Context<Self>) {
+ if self.read_only(cx) {
+ return;
+ }
let buffer = self.buffer.read(cx).snapshot(cx);
let selections = self.selections.all::<Point>(&self.display_snapshot(cx));
@@ -14335,12 +14396,18 @@ impl Editor {
}
pub fn cut(&mut self, _: &Cut, window: &mut Window, cx: &mut Context<Self>) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let item = self.cut_common(true, window, cx);
cx.write_to_clipboard(item);
}
pub fn kill_ring_cut(&mut self, _: &KillRingCut, window: &mut Window, cx: &mut Context<Self>) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
self.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
s.move_with(&mut |snapshot, sel| {
@@ -14707,6 +14774,9 @@ impl Editor {
}
pub fn paste(&mut self, _: &Paste, window: &mut Window, cx: &mut Context<Self>) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
if let Some(item) = cx.read_from_clipboard() {
let clipboard_string = item.entries().iter().find_map(|entry| match entry {
@@ -15342,6 +15412,9 @@ impl Editor {
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);
@@ -15373,6 +15446,9 @@ impl Editor {
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);
@@ -15460,6 +15536,9 @@ impl Editor {
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| {
@@ -15490,6 +15569,9 @@ impl Editor {
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| {
@@ -15566,6 +15648,9 @@ impl Editor {
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| {
@@ -15626,6 +15711,9 @@ impl Editor {
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_to_end_of_line(
@@ -15645,6 +15733,9 @@ impl Editor {
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_to_end_of_line(
@@ -17614,6 +17705,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::MovementAction, cx);
let buffer = self.buffer.read(cx).snapshot(cx);
@@ -19726,6 +19820,9 @@ impl Editor {
) -> Option<Task<Result<()>>> {
use language::ToOffset as _;
+ if self.read_only(cx) {
+ return None;
+ }
let provider = self.semantics_provider.clone()?;
let selection = self.selections.newest_anchor().clone();
let (cursor_buffer, cursor_buffer_position) = self
@@ -19914,6 +20011,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Task<Result<()>>> {
+ if self.read_only(cx) {
+ return None;
+ }
let rename = self.take_rename(false, window, cx)?;
let workspace = self.workspace()?.downgrade();
let (buffer, start) = self
@@ -20034,6 +20134,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Task<Result<()>>> {
+ if self.read_only(cx) {
+ return None;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let project = match &self.project {
@@ -20056,6 +20159,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Task<Result<()>>> {
+ if self.read_only(cx) {
+ return None;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let project = match &self.project {
@@ -20175,6 +20281,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Task<Result<()>>> {
+ if self.read_only(cx) {
+ return None;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let project = match &self.project {
Some(project) => project.clone(),
@@ -21756,6 +21865,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let buffers = self.buffer.read(cx).all_buffers();
@@ -21786,6 +21898,9 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
+ if self.read_only(cx) {
+ return;
+ }
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
let snapshot = self.snapshot(window, cx);
let hunks = snapshot.hunks_for_ranges(
@@ -24123,6 +24238,9 @@ impl Editor {
}
fn insert_uuid(&mut self, version: UuidVersion, 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| {
let edits = this
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs
index dd10b734d9f..c52a0d76bdb 100644
--- a/crates/editor/src/element.rs
+++ b/crates/editor/src/element.rs
@@ -249,65 +249,12 @@ impl EditorElement {
register_action(editor, window, Editor::select_page_down);
register_action(editor, window, Editor::select_page_up);
register_action(editor, window, Editor::cancel);
- register_action(editor, window, Editor::newline);
- register_action(editor, window, Editor::newline_above);
- register_action(editor, window, Editor::newline_below);
- register_action(editor, window, Editor::backspace);
register_action(editor, window, Editor::blame_hover);
- register_action(editor, window, Editor::delete);
- register_action(editor, window, Editor::tab);
register_action(editor, window, Editor::next_snippet_tabstop);
register_action(editor, window, Editor::previous_snippet_tabstop);
- register_action(editor, window, Editor::backtab);
- register_action(editor, window, Editor::indent);
- register_action(editor, window, Editor::outdent);
- register_action(editor, window, Editor::autoindent);
- register_action(editor, window, Editor::delete_line);
- register_action(editor, window, Editor::join_lines);
- register_action(editor, window, Editor::sort_lines_by_length);
- register_action(editor, window, Editor::sort_lines_case_sensitive);
- register_action(editor, window, Editor::sort_lines_case_insensitive);
- register_action(editor, window, Editor::reverse_lines);
- register_action(editor, window, Editor::shuffle_lines);
- register_action(editor, window, Editor::rotate_selections_forward);
- register_action(editor, window, Editor::rotate_selections_backward);
- register_action(editor, window, Editor::convert_indentation_to_spaces);
- register_action(editor, window, Editor::convert_indentation_to_tabs);
- register_action(editor, window, Editor::convert_to_upper_case);
- register_action(editor, window, Editor::convert_to_lower_case);
- register_action(editor, window, Editor::convert_to_title_case);
- register_action(editor, window, Editor::convert_to_snake_case);
- register_action(editor, window, Editor::convert_to_kebab_case);
- register_action(editor, window, Editor::convert_to_upper_camel_case);
- register_action(editor, window, Editor::convert_to_lower_camel_case);
- register_action(editor, window, Editor::convert_to_opposite_case);
- register_action(editor, window, Editor::convert_to_sentence_case);
- register_action(editor, window, Editor::toggle_case);
- register_action(editor, window, Editor::convert_to_rot13);
- register_action(editor, window, Editor::convert_to_rot47);
- register_action(editor, window, Editor::delete_to_previous_word_start);
- register_action(editor, window, Editor::delete_to_previous_subword_start);
- register_action(editor, window, Editor::delete_to_next_word_end);
- register_action(editor, window, Editor::delete_to_next_subword_end);
- register_action(editor, window, Editor::delete_to_beginning_of_line);
- register_action(editor, window, Editor::delete_to_end_of_line);
- register_action(editor, window, Editor::cut_to_end_of_line);
- register_action(editor, window, Editor::duplicate_line_up);
- register_action(editor, window, Editor::duplicate_line_down);
- register_action(editor, window, Editor::duplicate_selection);
- register_action(editor, window, Editor::move_line_up);
- register_action(editor, window, Editor::move_line_down);
- register_action(editor, window, Editor::transpose);
- register_action(editor, window, Editor::rewrap);
- register_action(editor, window, Editor::cut);
- register_action(editor, window, Editor::kill_ring_cut);
- register_action(editor, window, Editor::kill_ring_yank);
register_action(editor, window, Editor::copy);
register_action(editor, window, Editor::copy_and_trim);
register_action(editor, window, Editor::diff_clipboard_with_selection);
- register_action(editor, window, Editor::paste);
- register_action(editor, window, Editor::undo);
- register_action(editor, window, Editor::redo);
register_action(editor, window, Editor::move_page_up);
register_action(editor, window, Editor::move_page_down);
register_action(editor, window, Editor::next_screen);
@@ -324,16 +271,6 @@ impl EditorElement {
register_action(editor, window, |editor, _: &HalfPageDown, window, cx| {
editor.scroll_screen(&ScrollAmount::Page(0.5), window, cx)
});
- register_action(
- editor,
- window,
- |editor, HandleInput(text): &HandleInput, window, cx| {
- if text.is_empty() {
- return;
- }
- editor.handle_input(text, window, cx);
- },
- );
register_action(editor, window, |editor, _: &HalfPageUp, window, cx| {
editor.scroll_screen(&ScrollAmount::Page(-0.5), window, cx)
});
@@ -396,8 +333,6 @@ impl EditorElement {
register_action(editor, window, |editor, action, window, cx| {
editor.find_previous_match(action, window, cx).log_err();
});
- register_action(editor, window, Editor::toggle_comments);
- register_action(editor, window, Editor::toggle_block_comments);
register_action(editor, window, Editor::select_larger_syntax_node);
register_action(editor, window, Editor::select_smaller_syntax_node);
register_action(editor, window, Editor::select_next_syntax_node);
@@ -408,7 +343,6 @@ impl EditorElement {
Editor::select_to_start_of_larger_syntax_node,
);
register_action(editor, window, Editor::select_to_end_of_larger_syntax_node);
- register_action(editor, window, Editor::unwrap_syntax_node);
register_action(editor, window, Editor::move_to_start_of_larger_syntax_node);
register_action(editor, window, Editor::move_to_end_of_larger_syntax_node);
register_action(editor, window, Editor::select_enclosing_symbol);
@@ -546,54 +480,9 @@ impl EditorElement {
register_action(editor, window, Editor::go_to_next_reference);
register_action(editor, window, Editor::go_to_previous_symbol);
register_action(editor, window, Editor::go_to_next_symbol);
-
- register_action(editor, window, |editor, action, window, cx| {
- if let Some(task) = editor.format(action, window, cx) {
- editor.detach_and_notify_err(task, window, cx);
- } else {
- cx.propagate();
- }
- });
- if editor.read(cx).can_format_selections(cx) {
- register_action(editor, window, |editor, action, window, cx| {
- if let Some(task) = editor.format_selections(action, window, cx) {
- editor.detach_and_notify_err(task, window, cx);
- } else {
- cx.propagate();
- }
- });
- }
- register_action(editor, window, |editor, action, window, cx| {
- if let Some(task) = editor.organize_imports(action, window, cx) {
- editor.detach_and_notify_err(task, window, cx);
- } else {
- cx.propagate();
- }
- });
register_action(editor, window, Editor::restart_language_server);
register_action(editor, window, Editor::stop_language_server);
register_action(editor, window, Editor::show_character_palette);
- register_action(editor, window, |editor, action, window, cx| {
- if let Some(task) = editor.confirm_completion(action, window, cx) {
- editor.detach_and_notify_err(task, window, cx);
- } else {
- cx.propagate();
- }
- });
- register_action(editor, window, |editor, action, window, cx| {
- if let Some(task) = editor.confirm_completion_replace(action, window, cx) {
- editor.detach_and_notify_err(task, window, cx);
- } else {
- cx.propagate();
- }
- });
- register_action(editor, window, |editor, action, window, cx| {
- if let Some(task) = editor.confirm_completion_insert(action, window, cx) {
- editor.detach_and_notify_err(task, window, cx);
- } else {
- cx.propagate();
- }
- });
register_action(editor, window, |editor, action, window, cx| {
if let Some(task) = editor.compose_completion(action, window, cx) {
editor.detach_and_notify_err(task, window, cx);
@@ -601,27 +490,6 @@ impl EditorElement {
cx.propagate();
}
});
- register_action(editor, window, |editor, action, window, cx| {
- if let Some(task) = editor.confirm_code_action(action, window, cx) {
- editor.detach_and_notify_err(task, window, cx);
- } else {
- cx.propagate();
- }
- });
- register_action(editor, window, |editor, action, window, cx| {
- if let Some(task) = editor.rename(action, window, cx) {
- editor.detach_and_notify_err(task, window, cx);
- } else {
- cx.propagate();
- }
- });
- register_action(editor, window, |editor, action, window, cx| {
- if let Some(task) = editor.confirm_rename(action, window, cx) {
- editor.detach_and_notify_err(task, window, cx);
- } else {
- cx.propagate();
- }
- });
register_action(editor, window, |editor, action, window, cx| {
if let Some(task) = editor.find_all_references(action, window, cx) {
task.detach_and_log_err(cx);
@@ -638,21 +506,8 @@ impl EditorElement {
register_action(editor, window, Editor::context_menu_next);
register_action(editor, window, Editor::context_menu_last);
register_action(editor, window, Editor::display_cursor_names);
- register_action(editor, window, Editor::unique_lines_case_insensitive);
- register_action(editor, window, Editor::unique_lines_case_sensitive);
- register_action(editor, window, Editor::accept_next_word_edit_prediction);
- register_action(editor, window, Editor::accept_next_line_edit_prediction);
- register_action(editor, window, Editor::accept_edit_prediction);
- register_action(editor, window, Editor::restore_file);
- register_action(editor, window, Editor::git_restore);
- register_action(editor, window, Editor::restore_and_next);
- register_action(editor, window, Editor::apply_all_diff_hunks);
- register_action(editor, window, Editor::apply_selected_diff_hunks);
register_action(editor, window, Editor::open_active_item_in_terminal);
- register_action(editor, window, Editor::reload_file);
register_action(editor, window, Editor::spawn_nearest_task);
- register_action(editor, window, Editor::insert_uuid_v4);
- register_action(editor, window, Editor::insert_uuid_v7);
register_action(editor, window, Editor::open_selections_in_multibuffer);
register_action(editor, window, Editor::toggle_bookmark);
register_action(editor, window, Editor::go_to_next_bookmark);
@@ -662,9 +517,156 @@ impl EditorElement {
register_action(editor, window, Editor::enable_breakpoint);
register_action(editor, window, Editor::disable_breakpoint);
register_action(editor, window, Editor::toggle_read_only);
- register_action(editor, window, Editor::align_selections);
- if editor.read(cx).enable_wrap_selections_in_tag(cx) {
- register_action(editor, window, Editor::wrap_selections_in_tag);
+ register_action(editor, window, Editor::reload_file);
+
+ if !editor.read(cx).read_only(cx) {
+ register_action(editor, window, Editor::newline);
+ register_action(editor, window, Editor::newline_above);
+ register_action(editor, window, Editor::newline_below);
+ register_action(editor, window, Editor::backspace);
+ register_action(editor, window, Editor::delete);
+ register_action(editor, window, Editor::tab);
+ register_action(editor, window, Editor::backtab);
+ register_action(editor, window, Editor::indent);
+ register_action(editor, window, Editor::outdent);
+ register_action(editor, window, Editor::autoindent);
+ register_action(editor, window, Editor::delete_line);
+ register_action(editor, window, Editor::join_lines);
+ register_action(editor, window, Editor::sort_lines_by_length);
+ register_action(editor, window, Editor::sort_lines_case_sensitive);
+ register_action(editor, window, Editor::sort_lines_case_insensitive);
+ register_action(editor, window, Editor::unique_lines_case_insensitive);
+ register_action(editor, window, Editor::unique_lines_case_sensitive);
+ register_action(editor, window, Editor::reverse_lines);
+ register_action(editor, window, Editor::shuffle_lines);
+ register_action(editor, window, Editor::rotate_selections_forward);
+ register_action(editor, window, Editor::rotate_selections_backward);
+ register_action(editor, window, Editor::convert_indentation_to_spaces);
+ register_action(editor, window, Editor::convert_indentation_to_tabs);
+ register_action(editor, window, Editor::convert_to_upper_case);
+ register_action(editor, window, Editor::convert_to_lower_case);
+ register_action(editor, window, Editor::convert_to_title_case);
+ register_action(editor, window, Editor::convert_to_snake_case);
+ register_action(editor, window, Editor::convert_to_kebab_case);
+ register_action(editor, window, Editor::convert_to_upper_camel_case);
+ register_action(editor, window, Editor::convert_to_lower_camel_case);
+ register_action(editor, window, Editor::convert_to_opposite_case);
+ register_action(editor, window, Editor::convert_to_sentence_case);
+ register_action(editor, window, Editor::toggle_case);
+ register_action(editor, window, Editor::convert_to_rot13);
+ register_action(editor, window, Editor::convert_to_rot47);
+ register_action(editor, window, Editor::delete_to_previous_word_start);
+ register_action(editor, window, Editor::delete_to_previous_subword_start);
+ register_action(editor, window, Editor::delete_to_next_word_end);
+ register_action(editor, window, Editor::delete_to_next_subword_end);
+ register_action(editor, window, Editor::delete_to_beginning_of_line);
+ register_action(editor, window, Editor::delete_to_end_of_line);
+ register_action(editor, window, Editor::cut_to_end_of_line);
+ register_action(editor, window, Editor::duplicate_line_up);
+ register_action(editor, window, Editor::duplicate_line_down);
+ register_action(editor, window, Editor::duplicate_selection);
+ register_action(editor, window, Editor::move_line_up);
+ register_action(editor, window, Editor::move_line_down);
+ register_action(editor, window, Editor::transpose);
+ register_action(editor, window, Editor::rewrap);
+ register_action(editor, window, Editor::cut);
+ register_action(editor, window, Editor::kill_ring_cut);
+ register_action(editor, window, Editor::kill_ring_yank);
+ register_action(editor, window, Editor::paste);
+ register_action(editor, window, Editor::undo);
+ register_action(editor, window, Editor::redo);
+ register_action(editor, window, Editor::toggle_comments);
+ register_action(editor, window, Editor::toggle_block_comments);
+ register_action(editor, window, Editor::unwrap_syntax_node);
+ register_action(editor, window, Editor::accept_next_word_edit_prediction);
+ register_action(editor, window, Editor::accept_next_line_edit_prediction);
+ register_action(editor, window, Editor::accept_edit_prediction);
+ register_action(editor, window, Editor::restore_file);
+ register_action(editor, window, Editor::git_restore);
+ register_action(editor, window, Editor::restore_and_next);
+ register_action(editor, window, Editor::apply_all_diff_hunks);
+ register_action(editor, window, Editor::apply_selected_diff_hunks);
+ register_action(editor, window, Editor::insert_uuid_v4);
+ register_action(editor, window, Editor::insert_uuid_v7);
+ register_action(editor, window, Editor::align_selections);
+ if editor.read(cx).enable_wrap_selections_in_tag(cx) {
+ register_action(editor, window, Editor::wrap_selections_in_tag);
+ }
+ register_action(
+ editor,
+ window,
+ |editor, HandleInput(text): &HandleInput, window, cx| {
+ if text.is_empty() {
+ return;
+ }
+ editor.handle_input(text, window, cx);
+ },
+ );
+ register_action(editor, window, |editor, action, window, cx| {
+ if let Some(task) = editor.format(action, window, cx) {
+ editor.detach_and_notify_err(task, window, cx);
+ } else {
+ cx.propagate();
+ }
+ });
+ if editor.read(cx).can_format_selections(cx) {
+ register_action(editor, window, |editor, action, window, cx| {
+ if let Some(task) = editor.format_selections(action, window, cx) {
+ editor.detach_and_notify_err(task, window, cx);
+ } else {
+ cx.propagate();
+ }
+ });
+ }
+ register_action(editor, window, |editor, action, window, cx| {
+ if let Some(task) = editor.organize_imports(action, window, cx) {
+ editor.detach_and_notify_err(task, window, cx);
+ } else {
+ cx.propagate();
+ }
+ });
+ register_action(editor, window, |editor, action, window, cx| {
+ if let Some(task) = editor.confirm_completion(action, window, cx) {
+ editor.detach_and_notify_err(task, window, cx);
+ } else {
+ cx.propagate();
+ }
+ });
+ register_action(editor, window, |editor, action, window, cx| {
+ if let Some(task) = editor.confirm_completion_replace(action, window, cx) {
+ editor.detach_and_notify_err(task, window, cx);
+ } else {
+ cx.propagate();
+ }
+ });
+ register_action(editor, window, |editor, action, window, cx| {
+ if let Some(task) = editor.confirm_completion_insert(action, window, cx) {
+ editor.detach_and_notify_err(task, window, cx);
+ } else {
+ cx.propagate();
+ }
+ });
+ register_action(editor, window, |editor, action, window, cx| {
+ if let Some(task) = editor.confirm_code_action(action, window, cx) {
+ editor.detach_and_notify_err(task, window, cx);
+ } else {
+ cx.propagate();
+ }
+ });
+ register_action(editor, window, |editor, action, window, cx| {
+ if let Some(task) = editor.rename(action, window, cx) {
+ editor.detach_and_notify_err(task, window, cx);
+ } else {
+ cx.propagate();
+ }
+ });
+ register_action(editor, window, |editor, action, window, cx| {
+ if let Some(task) = editor.confirm_rename(action, window, cx) {
+ editor.detach_and_notify_err(task, window, cx);
+ } else {
+ cx.propagate();
+ }
+ });
}
}