Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Use * for italics as it doesn't break when used mid-word (#12523)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
t3chguy authored May 15, 2024
1 parent 77a7245 commit 667a754
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/editor/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<del>", "</del>");
Expand Down
8 changes: 4 additions & 4 deletions test/editor/operations-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -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" },
]);
});

Expand Down Expand Up @@ -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" },
]);
Expand Down

0 comments on commit 667a754

Please sign in to comment.