diff --git a/packages/app/src/components/markdown/html-ish.test.ts b/packages/app/src/components/markdown/html-ish.test.ts
index 15faec407..ac6f2ad8b 100644
--- a/packages/app/src/components/markdown/html-ish.test.ts
+++ b/packages/app/src/components/markdown/html-ish.test.ts
@@ -242,6 +242,14 @@ describe("splitHtmlishMarkdown", () => {
expect(splitHtmlishMarkdown(source)).toEqual([{ kind: "markdown", text: source }]);
});
+ it("keeps details inside inline code on native runtimes without copied array sorting", () => {
+ const source = "Use `Example
Body ` as an example.";
+
+ expect(withoutArrayToSorted(() => splitHtmlishMarkdown(source))).toEqual([
+ { kind: "markdown", text: source },
+ ]);
+ });
+
it("keeps details inside inline code as literal markdown", () => {
const source = "Use `Example
Body ` as an example.";
@@ -310,3 +318,15 @@ describe("splitHtmlishMarkdown", () => {
]);
});
});
+
+function withoutArrayToSorted(callback: () => T): T {
+ const descriptor = Object.getOwnPropertyDescriptor(Array.prototype, "toSorted");
+ Reflect.deleteProperty(Array.prototype, "toSorted");
+ try {
+ return callback();
+ } finally {
+ if (descriptor) {
+ Reflect.defineProperty(Array.prototype, "toSorted", descriptor);
+ }
+ }
+}
diff --git a/packages/app/src/components/markdown/html-ish.ts b/packages/app/src/components/markdown/html-ish.ts
index baaa121df..b68e734b5 100644
--- a/packages/app/src/components/markdown/html-ish.ts
+++ b/packages/app/src/components/markdown/html-ish.ts
@@ -681,7 +681,7 @@ function findClosingBacktickRun(
}
function mergeProtectedRanges(ranges: ProtectedMarkdownRange[]): ProtectedMarkdownRange[] {
- const sorted = ranges.toSorted((a, b) => a.start - b.start);
+ const sorted = [...ranges].sort((a, b) => a.start - b.start);
const merged: ProtectedMarkdownRange[] = [];
for (const range of sorted) {