Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

compose: Remove extra blank line before lists.

Aditya Kumar Kasaudhan79be013882d6
diff --git a/web/src/compose_ui.ts b/web/src/compose_ui.ts
index ca23042927e..9e52bba6d31 100644
--- a/web/src/compose_ui.ts
+++ b/web/src/compose_ui.ts
@@ -658,14 +658,10 @@ export let format_text = (
.split("\n")
.map((line, i) => mark(line, i))
.join("\n");
- // We always ensure a blank line before and after the list, as we want
+ // We always ensure a blank line after the list, as we want
// a clean separation between the list and the rest of the text, especially
// when the markdown is rendered.
- // Add blank line between text before and list if not already present.
- if (before_lines.length > 0 && before_lines.at(-1) !== "\n") {
- before_lines += "\n";
- }
// Add blank line between list and rest of text if not already present.
if (after_lines.length > 0 && after_lines.at(0) !== "\n") {
after_lines = "\n" + after_lines;
diff --git a/web/tests/compose_ui.test.cjs b/web/tests/compose_ui.test.cjs
index aeb1b636bf9..d0a6402a458 100644
--- a/web/tests/compose_ui.test.cjs
+++ b/web/tests/compose_ui.test.cjs
@@ -696,6 +696,10 @@ run_test("format_text - bulleted and numbered lists", ({override_rewire}) => {
compose_ui.format_text($textarea, "bulleted");
assert.equal(get_textarea_state(), "<first_item\nsecond_item>");
+ init_textarea_state("before_first\n<* first_item\n* second_item>\nafter_last");
+ compose_ui.format_text($textarea, "bulleted");
+ assert.equal(get_textarea_state(), "before_first\n<first_item\nsecond_item>\nafter_last");
+
// Toggling on numbered list
init_textarea_state("<first_item\nsecond_item>");
compose_ui.format_text($textarea, "numbered");
@@ -707,12 +711,12 @@ run_test("format_text - bulleted and numbered lists", ({override_rewire}) => {
init_textarea_state("before_first\nfirst_<item\nsecond>_item\nafter_last");
compose_ui.format_text($textarea, "numbered");
- // // Notice the blank lines inserted right before and after the list to visually demarcate it.
+ // // Notice the blank lines inserted right after the list to visually demarcate it.
// // Had the blank line after `second_item` not been inserted, `after_last` would have been
// // (wrongly) indented as part of the list's last item too.
assert.equal(
get_textarea_state(),
- "before_first\n\n<1. first_item\n2. second_item>\n\nafter_last",
+ "before_first\n<1. first_item\n2. second_item>\n\nafter_last",
);
// Toggling off numbered list