Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: kpdecker/jsdiff
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.3.0
Choose a base ref
...
head repository: kpdecker/jsdiff
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.3.1
Choose a head ref
  • 5 commits
  • 5 files changed
  • 2 contributors

Commits on Mar 13, 2015

  1. Copy the full SHA
    13b33ef View commit details
  2. Test case for #51 fix

    felicienfrancois committed Mar 13, 2015
    Copy the full SHA
    824c365 View commit details
  3. Merge pull request #52 from felicienfrancois/master

    Fix for #51 Wrong result of JsDiff.diffLines
    kpdecker committed Mar 13, 2015
    Copy the full SHA
    2c4b647 View commit details
  4. Update release notes

    kpdecker committed Mar 13, 2015
    Copy the full SHA
    284df85 View commit details
  5. v1.3.1

    kpdecker committed Mar 13, 2015
    Copy the full SHA
    018333d View commit details
Showing with 16 additions and 9 deletions.
  1. +1 −1 bower.json
  2. +1 −6 diff.js
  3. +1 −1 package.json
  4. +6 −1 release-notes.md
  5. +7 −0 test/diffTest.js
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsdiff",
"version": "1.3.0",
"version": "1.3.1",
"main": [
"diff.js"
],
7 changes: 1 addition & 6 deletions diff.js
Original file line number Diff line number Diff line change
@@ -270,13 +270,8 @@
lastLineLastChar = lastLine ? lastLine[lastLine.length - 1] : '';

// Merge lines that may contain windows new lines
if (line === '\n' && (lastLineLastChar === '\r' || lastLineLastChar === '\n')) {
if (this.ignoreTrim || lastLineLastChar === '\n'){
//to avoid merging to \n\n, remove \n and add \r\n.
if (line === '\n' && lastLineLastChar === '\r') {
retLines[retLines.length - 1] = retLines[retLines.length - 1].slice(0,-1) + '\r\n';
} else {
retLines[retLines.length - 1] += '\n';
}
} else if (line) {
if (this.ignoreTrim) {
line = line.trim();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "diff",
"version": "1.3.0",
"version": "1.3.1",
"description": "A javascript text diff implementation.",
"keywords": [
"diff",
7 changes: 6 additions & 1 deletion release-notes.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,12 @@

## Development

[Commits](https://github.com/kpdecker/jsdiff/compare/v1.3.0...master)
[Commits](https://github.com/kpdecker/jsdiff/compare/v1.3.1...master)

## v1.3.1 - March 13th, 2015
- [#52](https://github.com/kpdecker/jsdiff/pull/52) - Fix for #51 Wrong result of JsDiff.diffLines ([@felicienfrancois](https://api.github.com/users/felicienfrancois))

[Commits](https://github.com/kpdecker/jsdiff/compare/v1.3.0...v1.3.1)

## v1.3.0 - March 2nd, 2015
- [#47](https://github.com/kpdecker/jsdiff/pull/47) - Adding Diff Trimmed Lines ([@JamesGould123](https://api.github.com/users/JamesGould123))
7 changes: 7 additions & 0 deletions test/diffTest.js
Original file line number Diff line number Diff line change
@@ -198,6 +198,13 @@ describe('#diffLines', function() {
'line\r\nnew value\r\nline');
diff.convertChangesToXML(diffResult).should.equal('line\r\n<ins>new value\r\n</ins><del>old value \r\n</del>line');
});

it('should handle empty lines', function() {
var diffResult = diff.diffLines(
'line\n\nold value \n\nline',
'line\n\nnew value\n\nline');
diff.convertChangesToXML(diffResult).should.equal('line\n\n<ins>new value\n</ins><del>old value \n</del>\nline');
});
});

// Trimmed Line Diff