Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
lsp: Support on-type formatting request with newlines (#44882)
Piotr Osiewicz7889aaf3fb74
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 5149c01ebeb..20a8c75be5d 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -5018,6 +5018,9 @@ impl Editor {this.change_selections(Default::default(), window, cx, |s| s.select(new_selections));this.refresh_edit_prediction(true, false, window, cx);+ if let Some(task) = this.trigger_on_type_formatting("\n".to_owned(), window, cx) {+ task.detach_and_log_err(cx);+ }});}@@ -5082,6 +5085,9 @@ impl Editor {}}editor.edit(indent_edits, cx);+ if let Some(format) = editor.trigger_on_type_formatting("\n".to_owned(), window, cx) {+ format.detach_and_log_err(cx);+ }});}@@ -5144,6 +5150,9 @@ impl Editor {}}editor.edit(indent_edits, cx);+ if let Some(format) = editor.trigger_on_type_formatting("\n".to_owned(), window, cx) {+ format.detach_and_log_err(cx);+ }});}@@ -5454,7 +5463,7 @@ impl Editor {window: &mut Window,cx: &mut Context<Self>,) -> Option<Task<Result<()>>> {- if input.len() != 1 {+ if input.chars().count() != 1 {return None;}