Skip to content

Commit

Permalink
Merge pull request #113618 from shskwmt/113318-diff-empty-files
Browse files Browse the repository at this point in the history
Fixes #113318: Show having no change  when diffing two empty files
  • Loading branch information
alexdima committed Jan 4, 2021
2 parents 87c2cf1 + 604e246 commit 13317a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/vs/editor/common/diff/diffComputer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,13 @@ export class DiffComputer {

if (this.original.lines.length === 1 && this.original.lines[0].length === 0) {
// empty original => fast path
if (this.modified.lines.length === 1 && this.modified.lines[0].length === 0) {
return {
quitEarly: false,
changes: []
};
}

return {
quitEarly: false,
changes: [{
Expand Down
7 changes: 7 additions & 0 deletions src/vs/editor/test/common/diff/diffComputer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,13 @@ suite('Editor Diff - DiffComputer', () => {
assertDiff(original, modified, expected, true, false, true);
});

test('empty diff 5', () => {
let original = [''];
let modified = [''];
let expected: ILineChange[] = [];
assertDiff(original, modified, expected, true, false, true);
});

test('pretty diff 1', () => {
let original = [
'suite(function () {',
Expand Down

0 comments on commit 13317a9

Please sign in to comment.