From 57cd849e4682994fb5a5ef01ecd1e37ed48ade9b Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 5 Jun 2019 14:46:35 -0600 Subject: [PATCH 1/2] Don't build soft-wrapped line segments beyond the requested endScreenRow Co-Authored-By: Antonio Scandurra --- src/screen-line-builder.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/screen-line-builder.js b/src/screen-line-builder.js index 163042b8d1..aa98fd6672 100644 --- a/src/screen-line-builder.js +++ b/src/screen-line-builder.js @@ -27,8 +27,7 @@ class ScreenLineBuilder { this.bufferRow = this.displayLayer.findBoundaryPrecedingBufferRow(this.bufferRow) this.screenRow = this.displayLayer.translateBufferPositionWithSpatialIndex(Point(this.bufferRow, 0)).row - let endBufferRow; - ([endBufferRow, endScreenRow] = this.displayLayer.findBoundaryFollowingScreenRow(endScreenRow)) + const endBufferRow = this.displayLayer.translateScreenPositionWithSpatialIndex(Point(endScreenRow, Infinity)).row let didSeekDecorationIterator = false const decorationIterator = this.displayLayer.buffer.languageMode.buildHighlightIterator() @@ -55,10 +54,12 @@ class ScreenLineBuilder { if (nextHunk.newStart.row === this.screenRow) { if (nextHunk.newEnd.row > nextHunk.newStart.row) { this.screenRow++ + this.bufferColumn = nextHunk.oldEnd.column hunkIndex++ continue screenRowLoop } else { this.bufferRow = nextHunk.oldEnd.row + this.bufferColumn = nextHunk.oldEnd.column } } @@ -85,6 +86,12 @@ class ScreenLineBuilder { this.scopeIdsToReopen = decorationIterator.seek(Point(this.bufferRow, this.bufferColumn), endBufferRow) } + var prevCachedScreenLine = this.displayLayer.cachedScreenLines[this.screenRow - 1] + if (prevCachedScreenLine && prevCachedScreenLine.softWrapIndent >= 0) { + this.inLeadingWhitespace = false + if (prevCachedScreenLine.softWrapIndent > 0) this.emitIndentWhitespace(prevCachedScreenLine.softWrapIndent) + } + // This loop may visit multiple buffer rows if there are folds and // multiple screen rows if there are soft wraps. while (this.bufferColumn <= this.bufferLine.length) { @@ -93,6 +100,9 @@ class ScreenLineBuilder { while (nextHunk && nextHunk.oldStart.row === this.bufferRow && nextHunk.oldStart.column === this.bufferColumn) { if (this.displayLayer.isSoftWrapHunk(nextHunk)) { this.emitSoftWrap(nextHunk) + if (this.screenRow === endScreenRow) { + break screenRowLoop + } } else { this.emitFold(nextHunk, decorationIterator, endBufferRow) } @@ -248,7 +258,7 @@ class ScreenLineBuilder { this.emitCloseTag(this.getBuiltInScopeId(this.currentBuiltInClassNameFlags)) this.currentBuiltInClassNameFlags = 0 this.closeContainingScopes() - this.emitNewline() + this.emitNewline(nextHunk.newEnd.column) this.emitIndentWhitespace(nextHunk.newEnd.column) } @@ -280,11 +290,12 @@ class ScreenLineBuilder { this.bufferColumn = 0 } - emitNewline () { + emitNewline (softWrapIndent = -1) { const screenLine = { id: nextScreenLineId++, lineText: this.currentScreenLineText, - tags: this.currentScreenLineTags + tags: this.currentScreenLineTags, + softWrapIndent } this.pushScreenLine(screenLine) this.displayLayer.cachedScreenLines[this.screenRow] = screenLine From f84501199db166f0a34d1192616b2c9c0c627949 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 5 Jun 2019 15:57:39 -0600 Subject: [PATCH 2/2] 13.16.1-0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 56b2b21257..6cd40785b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "text-buffer", - "version": "13.16.0", + "version": "13.16.1-0", "description": "A container for large mutable strings with annotated regions", "main": "./lib/text-buffer", "scripts": {