From 667a7548a72ab348f7f40ae8421c5bad8b688347 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 15 May 2024 10:01:45 +0100 Subject: [PATCH] Use `*` for italics as it doesn't break when used mid-word (#12523) * Use `*` for italics as it doesn't break when used mid-word Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/editor/operations.ts | 2 +- test/editor/operations-test.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/editor/operations.ts b/src/editor/operations.ts index 13db8d56aa..ca8492b080 100644 --- a/src/editor/operations.ts +++ b/src/editor/operations.ts @@ -48,7 +48,7 @@ export function formatRange(range: Range, action: Formatting): void { toggleInlineFormat(range, "**"); break; case Formatting.Italics: - toggleInlineFormat(range, "_"); + toggleInlineFormat(range, "*"); break; case Formatting.Strikethrough: toggleInlineFormat(range, "", ""); diff --git a/test/editor/operations-test.ts b/test/editor/operations-test.ts index 2a456e4683..714dba42f0 100644 --- a/test/editor/operations-test.ts +++ b/test/editor/operations-test.ts @@ -101,7 +101,7 @@ describe("editor/operations: formatting operations", () => { expect(range.parts[0].text).toBe("world"); expect(model.serializeParts()).toEqual([{ text: "hello world!", type: "plain" }]); formatRange(range, Formatting.Italics); - expect(model.serializeParts()).toEqual([{ text: "hello _world_!", type: "plain" }]); + expect(model.serializeParts()).toEqual([{ text: "hello *world*!", type: "plain" }]); }); describe("escape backticks", () => { @@ -204,9 +204,9 @@ describe("editor/operations: formatting operations", () => { ]); formatRange(range, Formatting.Italics); expect(model.serializeParts()).toEqual([ - { text: "hello _there ", type: "plain" }, + { text: "hello *there ", type: "plain" }, { text: "@room", type: "at-room-pill" }, - { text: ", how are you_ doing?", type: "plain" }, + { text: ", how are you* doing?", type: "plain" }, ]); }); @@ -377,7 +377,7 @@ describe("editor/operations: formatting operations", () => { // We expect formatting to still happen in the first line as the caret should not jump down expect(model.serializeParts()).toEqual([ - { text: "hello _hello!_", type: "plain" }, + { text: "hello *hello!*", type: "plain" }, SERIALIZED_NEWLINE, { text: "world", type: "plain" }, ]);