-
Notifications
You must be signed in to change notification settings - Fork 513
Sort out behaviour of newlineIsToken and ignoreWhitespace #486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
97158ef
Sort out behaviour of newlineIsToken and ignoreWhitespace
ExplodingCabbage 8f8c31b
Fix linting errors I just introduced
ExplodingCabbage c9c01fc
Fix broken super call
ExplodingCabbage 84de1c0
Update failing test to reflect changes
ExplodingCabbage 0d03f2d
Update passing test to more completely test the new behaviour
ExplodingCabbage 7ce105d
Fix a gibberish test name
ExplodingCabbage 44cb0c5
Add test of newlineIsToken/ignoreWhitespace compatibility
ExplodingCabbage 3aba42f
Add tests that demonstrate a bug in the ignoreWhitespace/newlineIsTok…
ExplodingCabbage bc4302d
Document quirk of using the two options together
ExplodingCabbage eda3f59
Add release notes
ExplodingCabbage 51acd4c
Fix comment typo
ExplodingCabbage File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ describe('diff/line', function() { | |
'line\nnew value\nline'); | ||
expect(convertChangesToXML(diffResult)).to.equal('line\n<del>old value\n</del><ins>new value\n</ins>line'); | ||
}); | ||
it('should the same lines in diff', function() { | ||
it('should treat identical lines as equal', function() { | ||
const diffResult = diffLines( | ||
'line\nvalue\nline', | ||
'line\nvalue\nline'); | ||
|
@@ -128,7 +128,7 @@ describe('diff/line', function() { | |
'line\nnew value\nline'); | ||
expect(convertChangesToXML(diffResult)).to.equal('line\n<del>old value\n</del><ins>new value\n</ins>line'); | ||
}); | ||
it('should the same lines in diff', function() { | ||
it('should treat identical lines as equal', function() { | ||
const diffResult = diffTrimmedLines( | ||
'line\nvalue\nline', | ||
'line\nvalue\nline'); | ||
|
@@ -138,16 +138,39 @@ describe('diff/line', function() { | |
it('should ignore leading and trailing whitespace', function() { | ||
const diffResult = diffTrimmedLines( | ||
'line\nvalue \nline', | ||
'line\nvalue\nline'); | ||
expect(convertChangesToXML(diffResult)).to.equal('line\nvalue\nline'); | ||
'line \nvalue\nline'); | ||
expect(convertChangesToXML(diffResult)).to.equal('line \nvalue\nline'); | ||
}); | ||
|
||
it('should not consider adding whitespace to an empty line an insertion', function() { | ||
const diffResult = diffTrimmedLines('foo\n\nbar', 'foo\n \nbar'); | ||
expect(convertChangesToXML(diffResult)).to.equal('foo\n \nbar'); | ||
}); | ||
|
||
it('should handle windows line endings', function() { | ||
const diffResult = diffTrimmedLines( | ||
'line\r\nold value \r\nline', | ||
'line\r\nnew value\r\nline'); | ||
expect(convertChangesToXML(diffResult)).to.equal('line\r\n<del>old value\r\n</del><ins>new value\r\n</ins>line'); | ||
expect(convertChangesToXML(diffResult)).to.equal('line\r\n<del>old value \r\n</del><ins>new value\r\n</ins>line'); | ||
}); | ||
|
||
it('should be compatible with newlineIsToken', function() { | ||
const diffResult = diffTrimmedLines( | ||
'line1\nline2\n \nline4\n \n', | ||
'line1\nline2\n\n\nline4\n \n', | ||
{newlineIsToken: true} | ||
); | ||
expect(convertChangesToXML(diffResult)).to.equal('line1\nline2\n<del> </del>\n<ins>\n</ins>line4\n \n'); | ||
}); | ||
|
||
it( | ||
'should not consider adding whitespace to an empty line an insertion ' + | ||
'even in newlineIsToken mode where a token may be an empty string', | ||
function() { | ||
const diffResult = diffTrimmedLines('foo\n\nbar', 'foo\n \nbar', {newlineIsToken: true}); | ||
expect(convertChangesToXML(diffResult)).to.equal('foo\n \nbar'); | ||
} | ||
); | ||
Comment on lines
+166
to
+173
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, crap, I meant to remove this test before merging. It doesn't pass (and I added docs noting that!) |
||
}); | ||
|
||
describe('#diffLinesNL', function() { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.