Skip to content

feat: add ignoreWhitespace prop to ignore leading and trailing spaces - #98

Open
robbertbrak wants to merge 1 commit into
Aeolun:mainfrom
robbertbrak:feat/ignore-whitespace
Open

feat: add ignoreWhitespace prop to ignore leading and trailing spaces#98
robbertbrak wants to merge 1 commit into
Aeolun:mainfrom
robbertbrak:feat/ignore-whitespace

Conversation

@robbertbrak

Copy link
Copy Markdown

Lines that differ only in leading or trailing whitespace were always reported as changes, with no way to opt out.

compareMethod cannot be used for this: it is only threaded into the word diff computed within an already-changed line, while the line diff itself is hardcoded to diff.diffLines(old, new, { newlineIsToken: false }). Passing DiffMethod.TRIMMED_LINES therefore has no effect on which lines are marked as changed.

This PR adds an ignoreWhitespace prop that is forwarded to jsDiff's diffLines().

Lines that differ only in leading or trailing whitespace were always
reported as changes, with no way to opt out.

`compareMethod` cannot be used for this: it is only threaded into the
word diff computed *within* an already-changed line, while the line diff
itself is hardcoded to `diff.diffLines(old, new, { newlineIsToken: false })`.
Passing `DiffMethod.TRIMMED_LINES` therefore has no effect on which lines
are marked as changed.

Add an `ignoreWhitespace` prop that is forwarded to jsDiff's diffLines().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant