From 0550f5f0b413611015d8979562b5ca134be596d1 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 6 Dec 2026 08:43:43 +0800 Subject: [PATCH] refactor(desktop): reuse XML text ancestor order (#17317) --- src/domain/desktop/appTaskDraftText.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/domain/desktop/appTaskDraftText.ts b/src/domain/desktop/appTaskDraftText.ts index 815a398ab2..029aa3a684 100644 --- a/src/domain/desktop/appTaskDraftText.ts +++ b/src/domain/desktop/appTaskDraftText.ts @@ -268,17 +268,15 @@ const outsideRuns = (pointer: string, ends: Ends): readonly Candidate[] => { const parent = parentBelowRoot(named); if (parent === undefined) { const stopped = xmlParentPointer(named); - const chain = [...passed, named].filter( - (element, index, all) => all.indexOf(element) === index, - ); + passed.push(named); // A record directly under the document can still hold a save time. Leave a formatting run out when the paragraph remains. if (stopped !== undefined && noisy(stopped)) { - const narrower = withoutRuns(chain, noisy); + const narrower = withoutRuns(passed, noisy); if (narrower.length > 0) return narrower; } // generation-cap: ancestor tags climbed to name an element - return [current, ...[...passed.slice(1), named].slice(0, MAX_TAG_CLIMB)] - .filter((element, index, all) => all.indexOf(element) === index) + return passed + .slice(0, 1 + MAX_TAG_CLIMB) .map((element) => ({ element, pointer: element, identifier: false })); } passed.push(named); @@ -287,13 +285,7 @@ const outsideRuns = (pointer: string, ends: Ends): readonly Candidate[] => { } // An ancestor whose text joins a timestamp fails a later save that only restamps it. if (noisy(named)) { - const narrower = withoutRuns( - [...passed].filter( - (element, index, all) => - all.indexOf(element) === index && element !== named, - ), - noisy, - ); + const narrower = withoutRuns(passed, noisy); if (narrower.length > 0) return narrower; } const ranked = [