You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove linedelimiters, improve handling of Windows vs Unix line endings (#518)
* Remove linedelimiters
* Add a util for converting patches between Windows & Unix line endings
* Add some more utils
* Remove lingering linedelimiters references
* Fix linting errors
* Add patch line ending autoconversion and tests thereof
* Document autoConvertLineEndings
* Add release notes
* Add a failing test I need to fix
* Add stubs of more necessary tests
* More tests, fix a test name
* Make a test pass; fix some test names
* Get tests passing
* Improve coverage
* Add another test to get over the coverage threshold
* Remove meaningless/inappropriate 'Create patch' comment - both from original location and places I dumbly copied it to
Copy file name to clipboardexpand all lines: README.md
+1
Original file line number
Diff line number
Diff line change
@@ -125,6 +125,7 @@ Broadly, jsdiff's diff functions all take an old text and a new text and perform
125
125
The optional `options` object may have the following keys:
126
126
127
127
- `fuzzFactor`: Number of lines that are allowed to differ before rejecting a patch. Defaults to 0.
128
+
- `autoConvertLineEndings`: If `true`, and if the file to be patched consistently uses different line endings to the patch (i.e. either the file always uses Unix line endings while the patch uses Windows ones, or vice versa), then `applyPatch` will behave as if the line endings in the patch were the same as those in the source file. (If `false`, the patch will usually fail to apply in such circumstances since lines deleted in the patch won't be considered to match those in the source file.) Defaults to `true`.
128
129
-`compareLine(lineNumber, line, operation, patchContent)`: Callback used to compare to given lines to determine if they should be considered equal when patching. Defaults to strict equality but may be overridden to provide fuzzier comparison. Shouldreturnfalseif the lines should be rejected.
129
130
130
131
*`Diff.applyPatches(patch, options)`- applies one or more patches.
Copy file name to clipboardexpand all lines: release-notes.md
+1
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@
24
24
-[#486](https://github.com/kpdecker/jsdiff/pull/486)**The `ignoreWhitespace` option of `diffLines` behaves more sensibly now.**`value`s in returned change objects now include leading/trailing whitespace even when `ignoreWhitespace` is used, just like how with `ignoreCase` the `value`s still reflect the case of one of the original texts instead of being all-lowercase. `ignoreWhitespace` is also now compatible with `newlineIsToken`. Finally, **`diffTrimmedLines` is deprecated** (and removed from the docs) in favour of using `diffLines` with `ignoreWhitespace: true`; the two are, and always have been, equivalent.
25
25
-[#490](https://github.com/kpdecker/jsdiff/pull/490)**When calling diffing functions in async mode by passing a `callback` option, the diff result will now be passed as the *first* argument to the callback instead of the second.** (Previously, the first argument was never used at all and would always have value `undefined`.)
26
26
-[#489](github.com/kpdecker/jsdiff/pull/489)**`this.options` no longer exists on `Diff` objects.** Instead, `options` is now passed as an argument to methods that rely on options, like `equals(left, right, options)`. This fixes a race condition in async mode, where diffing behaviour could be changed mid-execution if a concurrent usage of the same `Diff` instances overwrote its `options`.
27
+
-[#518](https://github.com/kpdecker/jsdiff/pull/518)**`linedelimiters` no longer exists** on patch objects; instead, when a patch with Windows-style CRLF line endings is parsed, **the lines in `lines` will end with `\r`**. There is now a **new `autoConvertLineEndings` option, on by default**, which makes it so that when a patch with Windows-style line endings is applied to a source file with Unix style line endings, the patch gets autoconverted to use Unix-style line endings, and when a patch with Unix-style line endings is applied to a source file with Windows-style line endings, it gets autoconverted to use Windows-style line endings.
0 commit comments