Skip to content

Commit 96abeff

Browse files
committed
fix(text): deleteEveryBlock may delete the wrong lines (#1)
Closes #1
1 parent a42fa3c commit 96abeff

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

src/text.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ export class Text {
225225
}
226226
} else if (matches > 0) {
227227
if (line.match(patterns[0])) {
228+
matchRow = index;
228229
matches = 1;
229230
} else {
230231
matches = 0;

tests/text.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,12 @@ describe('Text', () => {
279279
text.deleteEveryBlock(['one', 'one']);
280280
expect(text.content).to.equal('one\ntwo');
281281
});
282+
283+
it('should correctly handle repeated first line of block (issue #1)', () => {
284+
const text = new Text('one\ntwo\nthree\n');
285+
text.deleteEveryBlock(['', 'three']);
286+
expect(text.content).to.equal('one\n');
287+
});
282288
});
283289

284290
describe('append', () => {

0 commit comments

Comments
 (0)