Skip to content

Commit

Permalink
Fixes PieceTreeBase.equal (microsoft#181125)
Browse files Browse the repository at this point in the history
Fixes `PieceTreeBase.equal` (fixes microsoft/vscode-internalbacklog#4025)
  • Loading branch information
alexdima authored May 1, 2023
1 parent e410e7c commit 3862229
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export class PieceTreeBase {
return false;
}

const offset = 0;
let offset = 0;
const ret = this.iterate(this.root, node => {
if (node === SENTINEL) {
return true;
Expand All @@ -385,6 +385,7 @@ export class PieceTreeBase {
const endPosition = other.nodeAt(offset + len);
const val = other.getValueInRange2(startPosition, endPosition);

offset += len;
return str === val;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,12 @@ suite('buffer api', () => {
assert(!a.equal(d));
});

test('equal with more chunks', () => {
const a = createTextBuffer(['ab', 'cd', 'e']);
const b = createTextBuffer(['ab', 'c', 'de']);
assert(a.equal(b));
});

test('equal 2, empty buffer', () => {
const a = createTextBuffer(['']);
const b = createTextBuffer(['']);
Expand Down

0 comments on commit 3862229

Please sign in to comment.