From 7889aaf3fb74bee4cab6f1ea1715eb08163e6afd Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 15 Dec 2025 14:44:01 +0100 Subject: [PATCH] lsp: Support on-type formatting request with newlines (#44882) We called out to `request_on_type_formatting` only in handle_input function, but newlines are actually handled by editor::Newline action. Closes #12383 Release Notes: - Added support for on-type formatting with newlines. --- crates/editor/src/editor.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 5149c01ebeb5e52c4eb093de0c1d10690b2a7035..20a8c75be5dc4f966b0b1002e2979273435fd71c 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, ) -> Option>> { - if input.len() != 1 { + if input.chars().count() != 1 { return None; }