Skip to content

fix: textdiff - preserveWhitespace option - #51

Merged
DoneDeal0 merged 1 commit into
mainfrom
preserve-extra-spacing-textdiff
Sep 2, 2026
Merged

fix: textdiff - preserveWhitespace option#51
DoneDeal0 merged 1 commit into
mainfrom
preserve-extra-spacing-textdiff

Conversation

@DoneDeal0

Copy link
Copy Markdown
Owner
  • Added the preserveWhitespace option to getTextDiff.
  • Increased performance of getTextDiff.

preserveWhiteSpace: true

// input
getTextDiff("  hello world", "hello world", { separation: "word", preserveWhitespace: true }),

// output
{
  type: "text",
  status: "updated",
  diff: [
    { value: "  hello", index: null, previousIndex: 0, status: "deleted" },
    { value: "hello", index: 0, previousIndex: null, status: "added" },
    { value: " world", index: 1, previousIndex: 1, status: "equal" },
  ],
}

preserveWhiteSpace: false

// input
getTextDiff(". hello world", "hello world", { separation: "word" }),

// output
{
  type: "text",
  status: "equal",
  diff: [
    { value: "hello", index: 0, previousIndex: 0, status: "equal" },
    { value: "world", index: 1, previousIndex: 1, status: "equal" },
  ],
}

@DoneDeal0
DoneDeal0 force-pushed the preserve-extra-spacing-textdiff branch from f5d7e04 to c9d1fab Compare September 1, 2026 19:05
@DoneDeal0 DoneDeal0 self-assigned this Sep 1, 2026
@DoneDeal0
DoneDeal0 merged commit a6449db into main Sep 2, 2026
1 check passed
@DoneDeal0
DoneDeal0 deleted the preserve-extra-spacing-textdiff branch September 2, 2026 18:36
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 4.2.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant