Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
editor: Preserve the trailing newline when converting case (#63463)
Ali91c57e81470e
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex a3449e415ee..fb31e036746 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -7265,7 +7265,7 @@ impl Editor {}fn convert_text_case(text: &str, case: Case) -> String {- text.lines()+ text.split('\n').map(|line| {let trimmed_start = line.trim_start();let leading = &line[..line.len() - trimmed_start.len()];diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rsindex dbc3b66c13a..6dd6376b4cf 100644--- a/crates/editor/src/editor_tests.rs+++ b/crates/editor/src/editor_tests.rs@@ -8283,6 +8283,16 @@ async fn test_manipulate_text(cx: &mut TestAppContext) {« hello_world\t\tˇ»"});+ cx.set_state(indoc! {"+ «hello world+ ˇ»goodbye+ "});+ cx.update_editor(|e, window, cx| e.convert_to_snake_case(&ConvertToSnakeCase, window, cx));+ cx.assert_editor_state(indoc! {"+ «hello_world+ ˇ»goodbye+ "});+// Test selections with `line_mode() = true`.cx.update_editor(|editor, _window, _cx| editor.selections.set_line_mode(true));cx.set_state(indoc! {"