diff --git a/src/text.ts b/src/text.ts index 3cc55c9..1c9013e 100644 --- a/src/text.ts +++ b/src/text.ts @@ -518,7 +518,10 @@ class LineCursor implements TextIterator { next(skip = 0) { let {done, lineBreak, value} = this.inner.next(skip) - if (done) { + if (done && this.afterBreak) { + this.value = "" + this.afterBreak = false + } else if (done) { this.done = true this.value = "" } else if (lineBreak) { diff --git a/test/test-text.ts b/test/test-text.ts index 5e7b4d6..bdadbdb 100644 --- a/test/test-text.ts +++ b/test/test-text.ts @@ -177,7 +177,8 @@ describe("Text", () => { ist(get(), "ab\ncde\n\n\nf\n\ng") ist(get(1, doc.lines + 1), "ab\ncde\n\n\nf\n\ng") ist(get(2, 3), "cde") - ist(get(1, 1), "") + ist(get(2, 3), "cde") + ist(get(1, 5), "ab\ncde\n\n") ist(get(2, 1), "") ist(get(3), "\n\nf\n\ng") })