From 0afa9bb21ccc3cae1f8f3ed6e4e6a250ef6e65be Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 17 Feb 2016 10:02:48 +0100 Subject: [PATCH 01/10] Don't update foldable status, ever --- spec/tokenized-buffer-spec.coffee | 81 ------------------------------- src/tokenized-buffer.coffee | 1 + 2 files changed, 1 insertion(+), 81 deletions(-) diff --git a/spec/tokenized-buffer-spec.coffee b/spec/tokenized-buffer-spec.coffee index 72b292cc2..14843ddb8 100644 --- a/spec/tokenized-buffer-spec.coffee +++ b/spec/tokenized-buffer-spec.coffee @@ -903,87 +903,6 @@ describe "TokenizedBuffer", -> expect(tokenizedBuffer.tokenizedLineForRow(9).indentLevel).toBe 2 expect(tokenizedBuffer.tokenizedLineForRow(10).indentLevel).toBe 2 # } - describe ".foldable on tokenized lines", -> - changes = null - - beforeEach -> - changes = [] - buffer = atom.project.bufferForPathSync('sample.js') - buffer.insert [10, 0], " // multi-line\n // comment\n // block\n" - buffer.insert [0, 0], "// multi-line\n// comment\n// block\n" - tokenizedBuffer = new TokenizedBuffer({ - buffer, config: atom.config, grammarRegistry: atom.grammars, packageManager: atom.packages, assert: atom.assert - }) - fullyTokenize(tokenizedBuffer) - tokenizedBuffer.onDidChange (change) -> - delete change.bufferChange - changes.push(change) - - it "sets .foldable to true on the first line of multi-line comments", -> - expect(tokenizedBuffer.tokenizedLineForRow(0).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(1).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(2).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(3).foldable).toBe true # because of indent - expect(tokenizedBuffer.tokenizedLineForRow(13).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(14).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(15).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(16).foldable).toBe false - - buffer.insert([0, Infinity], '\n') - expect(changes).toEqual [{start: 0, end: 1, delta: 1}] - - expect(tokenizedBuffer.tokenizedLineForRow(0).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(1).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(2).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(3).foldable).toBe false - - changes = [] - buffer.undo() - expect(changes).toEqual [{start: 0, end: 2, delta: -1}] - expect(tokenizedBuffer.tokenizedLineForRow(0).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(1).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(2).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(3).foldable).toBe true # because of indent - - it "sets .foldable to true on non-comment lines that precede an increase in indentation", -> - buffer.insert([2, 0], ' ') # commented lines preceding an indent aren't foldable - expect(tokenizedBuffer.tokenizedLineForRow(1).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(2).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(3).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(4).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(5).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(6).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(7).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(8).foldable).toBe false - - changes = [] - buffer.insert([7, 0], ' ') - expect(changes).toEqual [{start: 6, end: 7, delta: 0}] - expect(tokenizedBuffer.tokenizedLineForRow(6).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(7).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(8).foldable).toBe false - - changes = [] - buffer.undo() - expect(changes).toEqual [{start: 6, end: 7, delta: 0}] - expect(tokenizedBuffer.tokenizedLineForRow(6).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(7).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(8).foldable).toBe false - - changes = [] - buffer.insert([7, 0], " \n x\n") - expect(changes).toEqual [{start: 6, end: 7, delta: 2}] - expect(tokenizedBuffer.tokenizedLineForRow(6).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(7).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(8).foldable).toBe false - - changes = [] - buffer.insert([9, 0], " ") - expect(changes).toEqual [{start: 9, end: 9, delta: 0}] - expect(tokenizedBuffer.tokenizedLineForRow(6).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(7).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(8).foldable).toBe false - describe "when the buffer is configured with the null grammar", -> it "uses the placeholder tokens and does not actually tokenize using the grammar", -> spyOn(atom.grammars.nullGrammar, 'tokenizeLine').andCallThrough() diff --git a/src/tokenized-buffer.coffee b/src/tokenized-buffer.coffee index 0fdf4eea8..5a95d9f15 100644 --- a/src/tokenized-buffer.coffee +++ b/src/tokenized-buffer.coffee @@ -288,6 +288,7 @@ class TokenizedBuffer extends Model row - increment updateFoldableStatus: (startRow, endRow) -> + return [startRow, endRow] return [startRow, endRow] if @largeFileMode scanStartRow = @buffer.previousNonBlankRow(startRow) ? startRow From 012fa354c41a495983588f7148c5413c28209e96 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 17 Feb 2016 10:28:38 +0100 Subject: [PATCH 02/10] Add TokenizedBuffer.prototype.foldableRowsForRowRange --- src/display-buffer.coffee | 3 +++ src/text-editor-presenter.coffee | 3 ++- src/text-editor.coffee | 5 ++++- src/tokenized-buffer.coffee | 24 +++++------------------- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/display-buffer.coffee b/src/display-buffer.coffee index 8b95656f9..8015f2df2 100644 --- a/src/display-buffer.coffee +++ b/src/display-buffer.coffee @@ -413,6 +413,9 @@ class DisplayBuffer extends Model isFoldedAtScreenRow: (screenRow) -> @largestFoldContainingBufferRow(@bufferRowForScreenRow(screenRow))? + foldableBufferRowsForBufferRowRange: (startRow, endRow) -> + @tokenizedBuffer.foldableRowsForRowRange(startRow, endRow) + # Destroys the fold with the given id destroyFoldWithId: (id) -> @foldsByMarkerId[id]?.destroy() diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index a36c860ed..147eaa962 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -599,6 +599,7 @@ class TextEditorPresenter if endRow > startRow bufferRows = @model.bufferRowsForScreenRows(startRow, endRow - 1) + foldableBufferRows = @model.foldableBufferRowsForBufferRowRange(bufferRows[0], bufferRows[bufferRows.length - 1]) for bufferRow, i in bufferRows if bufferRow is lastBufferRow softWrapped = true @@ -609,7 +610,7 @@ class TextEditorPresenter screenRow = startRow + i line = @model.tokenizedLineForScreenRow(screenRow) decorationClasses = @lineNumberDecorationClassesForRow(screenRow) - foldable = @model.isFoldableAtScreenRow(screenRow) + foldable = foldableBufferRows.has(bufferRow) blockDecorationsBeforeCurrentScreenRowHeight = @lineTopIndex.pixelPositionAfterBlocksForRow(screenRow) - @lineTopIndex.pixelPositionBeforeBlocksForRow(screenRow) blockDecorationsHeight = blockDecorationsBeforeCurrentScreenRowHeight if screenRow % @tileSize isnt 0 diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 55f6d84ad..6c80cfc01 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -2940,7 +2940,7 @@ class TextEditor extends Model # Returns a {Boolean}. isFoldableAtBufferRow: (bufferRow) -> # @languageMode.isFoldableAtBufferRow(bufferRow) - @displayBuffer.tokenizedBuffer.tokenizedLineForRow(bufferRow)?.foldable ? false + @foldableBufferRowsForBufferRowRange(bufferRow, bufferRow).has(bufferRow) # Extended: Determine whether the given row in screen coordinates is foldable. # @@ -2953,6 +2953,9 @@ class TextEditor extends Model bufferRow = @displayBuffer.bufferRowForScreenRow(screenRow) @isFoldableAtBufferRow(bufferRow) + foldableBufferRowsForBufferRowRange: (startRow, endRow) -> + @displayBuffer.foldableBufferRowsForBufferRowRange(startRow, endRow) + # Extended: Fold the given buffer row if it isn't currently folded, and unfold # it otherwise. toggleFoldAtBufferRow: (bufferRow) -> diff --git a/src/tokenized-buffer.coffee b/src/tokenized-buffer.coffee index 5a95d9f15..055e3fe47 100644 --- a/src/tokenized-buffer.coffee +++ b/src/tokenized-buffer.coffee @@ -210,8 +210,6 @@ class TokenizedBuffer extends Model @validateRow(endRow) @invalidateRow(endRow + 1) unless filledRegion - [startRow, endRow] = @updateFoldableStatus(startRow, endRow) - event = {start: startRow, end: endRow, delta: 0} @emitter.emit 'did-change', event @@ -271,9 +269,6 @@ class TokenizedBuffer extends Model if newEndStack and not _.isEqual(newEndStack, previousEndStack) @invalidateRow(end + delta + 1) - [start, end] = @updateFoldableStatus(start, end + delta) - end -= delta - event = {start, end, delta, bufferChange: e} @emitter.emit 'did-change', event @@ -287,23 +282,14 @@ class TokenizedBuffer extends Model row - increment - updateFoldableStatus: (startRow, endRow) -> - return [startRow, endRow] - return [startRow, endRow] if @largeFileMode - + foldableRowsForRowRange: (startRow, endRow) -> scanStartRow = @buffer.previousNonBlankRow(startRow) ? startRow scanStartRow-- while scanStartRow > 0 and @tokenizedLineForRow(scanStartRow).isComment() scanEndRow = @buffer.nextNonBlankRow(endRow) ? endRow - - for row in [scanStartRow..scanEndRow] by 1 - foldable = @isFoldableAtRow(row) - line = @tokenizedLineForRow(row) - unless line.foldable is foldable - line.foldable = foldable - startRow = Math.min(startRow, row) - endRow = Math.max(endRow, row) - - [startRow, endRow] + foldableRows = new Set + for row in [scanStartRow..scanEndRow] by 1 when @isFoldableAtRow(row) + foldableRows.add(row) + foldableRows isFoldableAtRow: (row) -> if @largeFileMode From d05dfa6efe2131f468cca75dd407f0a992dceb4e Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 17 Feb 2016 10:29:38 +0100 Subject: [PATCH 03/10] :racehorse: Update lines state only in pre-measurement phase --- src/text-editor-presenter.coffee | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 147eaa962..48f269b9d 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -90,7 +90,7 @@ class TextEditorPresenter @updateLineDecorations() @updateBlockDecorations() - @updateTilesState() + @updateTilesState(true) @updating = false @state @@ -112,7 +112,7 @@ class TextEditorPresenter @updateHiddenInputState() @updateContentState() @updateHighlightDecorations() if @shouldUpdateDecorations - @updateTilesState() + @updateTilesState(false) @updateCursorsState() @updateOverlaysState() @updateLineNumberGutterState() @@ -327,7 +327,7 @@ class TextEditorPresenter clearScreenRowsToMeasure: -> @screenRowsToMeasure = [] - updateTilesState: -> + updateTilesState: (updateLinesState) -> return unless @startRow? and @endRow? and @lineHeight? screenRows = @getScreenRows() @@ -367,8 +367,9 @@ class TextEditorPresenter gutterTile.display = "block" gutterTile.zIndex = zIndex - @updateLinesState(tile, rowsWithinTile) - @updateLineNumbersState(gutterTile, rowsWithinTile) + if updateLinesState + @updateLinesState(tile, rowsWithinTile) + @updateLineNumbersState(gutterTile, rowsWithinTile) visibleTiles[tileStartRow] = true zIndex++ From 2c71a448b3b1397dcd3e451484750c037909e5b2 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 17 Feb 2016 11:04:19 +0100 Subject: [PATCH 04/10] Put foldable specs back --- spec/tokenized-buffer-spec.coffee | 81 +++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/spec/tokenized-buffer-spec.coffee b/spec/tokenized-buffer-spec.coffee index 14843ddb8..72b292cc2 100644 --- a/spec/tokenized-buffer-spec.coffee +++ b/spec/tokenized-buffer-spec.coffee @@ -903,6 +903,87 @@ describe "TokenizedBuffer", -> expect(tokenizedBuffer.tokenizedLineForRow(9).indentLevel).toBe 2 expect(tokenizedBuffer.tokenizedLineForRow(10).indentLevel).toBe 2 # } + describe ".foldable on tokenized lines", -> + changes = null + + beforeEach -> + changes = [] + buffer = atom.project.bufferForPathSync('sample.js') + buffer.insert [10, 0], " // multi-line\n // comment\n // block\n" + buffer.insert [0, 0], "// multi-line\n// comment\n// block\n" + tokenizedBuffer = new TokenizedBuffer({ + buffer, config: atom.config, grammarRegistry: atom.grammars, packageManager: atom.packages, assert: atom.assert + }) + fullyTokenize(tokenizedBuffer) + tokenizedBuffer.onDidChange (change) -> + delete change.bufferChange + changes.push(change) + + it "sets .foldable to true on the first line of multi-line comments", -> + expect(tokenizedBuffer.tokenizedLineForRow(0).foldable).toBe true + expect(tokenizedBuffer.tokenizedLineForRow(1).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(2).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(3).foldable).toBe true # because of indent + expect(tokenizedBuffer.tokenizedLineForRow(13).foldable).toBe true + expect(tokenizedBuffer.tokenizedLineForRow(14).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(15).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(16).foldable).toBe false + + buffer.insert([0, Infinity], '\n') + expect(changes).toEqual [{start: 0, end: 1, delta: 1}] + + expect(tokenizedBuffer.tokenizedLineForRow(0).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(1).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(2).foldable).toBe true + expect(tokenizedBuffer.tokenizedLineForRow(3).foldable).toBe false + + changes = [] + buffer.undo() + expect(changes).toEqual [{start: 0, end: 2, delta: -1}] + expect(tokenizedBuffer.tokenizedLineForRow(0).foldable).toBe true + expect(tokenizedBuffer.tokenizedLineForRow(1).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(2).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(3).foldable).toBe true # because of indent + + it "sets .foldable to true on non-comment lines that precede an increase in indentation", -> + buffer.insert([2, 0], ' ') # commented lines preceding an indent aren't foldable + expect(tokenizedBuffer.tokenizedLineForRow(1).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(2).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(3).foldable).toBe true + expect(tokenizedBuffer.tokenizedLineForRow(4).foldable).toBe true + expect(tokenizedBuffer.tokenizedLineForRow(5).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(6).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(7).foldable).toBe true + expect(tokenizedBuffer.tokenizedLineForRow(8).foldable).toBe false + + changes = [] + buffer.insert([7, 0], ' ') + expect(changes).toEqual [{start: 6, end: 7, delta: 0}] + expect(tokenizedBuffer.tokenizedLineForRow(6).foldable).toBe true + expect(tokenizedBuffer.tokenizedLineForRow(7).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(8).foldable).toBe false + + changes = [] + buffer.undo() + expect(changes).toEqual [{start: 6, end: 7, delta: 0}] + expect(tokenizedBuffer.tokenizedLineForRow(6).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(7).foldable).toBe true + expect(tokenizedBuffer.tokenizedLineForRow(8).foldable).toBe false + + changes = [] + buffer.insert([7, 0], " \n x\n") + expect(changes).toEqual [{start: 6, end: 7, delta: 2}] + expect(tokenizedBuffer.tokenizedLineForRow(6).foldable).toBe true + expect(tokenizedBuffer.tokenizedLineForRow(7).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(8).foldable).toBe false + + changes = [] + buffer.insert([9, 0], " ") + expect(changes).toEqual [{start: 9, end: 9, delta: 0}] + expect(tokenizedBuffer.tokenizedLineForRow(6).foldable).toBe true + expect(tokenizedBuffer.tokenizedLineForRow(7).foldable).toBe false + expect(tokenizedBuffer.tokenizedLineForRow(8).foldable).toBe false + describe "when the buffer is configured with the null grammar", -> it "uses the placeholder tokens and does not actually tokenize using the grammar", -> spyOn(atom.grammars.nullGrammar, 'tokenizeLine').andCallThrough() From a613fa5133b4671c77aa08d2d5ce92785d0137db Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 17 Feb 2016 11:17:24 +0100 Subject: [PATCH 05/10] Adapt specs to use the new API --- spec/tokenized-buffer-spec.coffee | 106 +++++++++++++++--------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/spec/tokenized-buffer-spec.coffee b/spec/tokenized-buffer-spec.coffee index 72b292cc2..0f5c9c52d 100644 --- a/spec/tokenized-buffer-spec.coffee +++ b/spec/tokenized-buffer-spec.coffee @@ -903,7 +903,7 @@ describe "TokenizedBuffer", -> expect(tokenizedBuffer.tokenizedLineForRow(9).indentLevel).toBe 2 expect(tokenizedBuffer.tokenizedLineForRow(10).indentLevel).toBe 2 # } - describe ".foldable on tokenized lines", -> + describe "::foldableRowsForRowRange(startRow, endRow)", -> changes = null beforeEach -> @@ -915,74 +915,74 @@ describe "TokenizedBuffer", -> buffer, config: atom.config, grammarRegistry: atom.grammars, packageManager: atom.packages, assert: atom.assert }) fullyTokenize(tokenizedBuffer) - tokenizedBuffer.onDidChange (change) -> - delete change.bufferChange - changes.push(change) - it "sets .foldable to true on the first line of multi-line comments", -> - expect(tokenizedBuffer.tokenizedLineForRow(0).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(1).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(2).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(3).foldable).toBe true # because of indent - expect(tokenizedBuffer.tokenizedLineForRow(13).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(14).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(15).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(16).foldable).toBe false + it "includes the first line of multi-line comments", -> + foldableRows = tokenizedBuffer.foldableRowsForRowRange(0, 16) + expect(foldableRows.has(0)).toBe true + expect(foldableRows.has(1)).toBe false + expect(foldableRows.has(2)).toBe false + expect(foldableRows.has(3)).toBe true # because of indent + expect(foldableRows.has(13)).toBe true + expect(foldableRows.has(14)).toBe false + expect(foldableRows.has(15)).toBe false + expect(foldableRows.has(16)).toBe false buffer.insert([0, Infinity], '\n') - expect(changes).toEqual [{start: 0, end: 1, delta: 1}] - expect(tokenizedBuffer.tokenizedLineForRow(0).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(1).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(2).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(3).foldable).toBe false + foldableRows = tokenizedBuffer.foldableRowsForRowRange(0, 3) + expect(foldableRows.has(0)).toBe false + expect(foldableRows.has(1)).toBe false + expect(foldableRows.has(2)).toBe true + expect(foldableRows.has(3)).toBe false - changes = [] buffer.undo() - expect(changes).toEqual [{start: 0, end: 2, delta: -1}] - expect(tokenizedBuffer.tokenizedLineForRow(0).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(1).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(2).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(3).foldable).toBe true # because of indent - it "sets .foldable to true on non-comment lines that precede an increase in indentation", -> + foldableRows = tokenizedBuffer.foldableRowsForRowRange(0, 3) + expect(foldableRows.has(0)).toBe true + expect(foldableRows.has(1)).toBe false + expect(foldableRows.has(2)).toBe false + expect(foldableRows.has(3)).toBe true # because of indent + + it "includes non-comment lines that precede an increase in indentation", -> buffer.insert([2, 0], ' ') # commented lines preceding an indent aren't foldable - expect(tokenizedBuffer.tokenizedLineForRow(1).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(2).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(3).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(4).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(5).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(6).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(7).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(8).foldable).toBe false - changes = [] + foldableRows = tokenizedBuffer.foldableRowsForRowRange(0, 8) + expect(foldableRows.has(1)).toBe false + expect(foldableRows.has(2)).toBe false + expect(foldableRows.has(3)).toBe true + expect(foldableRows.has(4)).toBe true + expect(foldableRows.has(5)).toBe false + expect(foldableRows.has(6)).toBe false + expect(foldableRows.has(7)).toBe true + expect(foldableRows.has(8)).toBe false + buffer.insert([7, 0], ' ') - expect(changes).toEqual [{start: 6, end: 7, delta: 0}] - expect(tokenizedBuffer.tokenizedLineForRow(6).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(7).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(8).foldable).toBe false - changes = [] + foldableRows = tokenizedBuffer.foldableRowsForRowRange(6, 8) + expect(foldableRows.has(6)).toBe true + expect(foldableRows.has(7)).toBe false + expect(foldableRows.has(8)).toBe false + buffer.undo() - expect(changes).toEqual [{start: 6, end: 7, delta: 0}] - expect(tokenizedBuffer.tokenizedLineForRow(6).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(7).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(8).foldable).toBe false - changes = [] + foldableRows = tokenizedBuffer.foldableRowsForRowRange(6, 8) + expect(foldableRows.has(6)).toBe false + expect(foldableRows.has(7)).toBe true + expect(foldableRows.has(8)).toBe false + buffer.insert([7, 0], " \n x\n") - expect(changes).toEqual [{start: 6, end: 7, delta: 2}] - expect(tokenizedBuffer.tokenizedLineForRow(6).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(7).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(8).foldable).toBe false - changes = [] + foldableRows = tokenizedBuffer.foldableRowsForRowRange(6, 8) + expect(foldableRows.has(6)).toBe true + expect(foldableRows.has(7)).toBe false + expect(foldableRows.has(8)).toBe false + buffer.insert([9, 0], " ") - expect(changes).toEqual [{start: 9, end: 9, delta: 0}] - expect(tokenizedBuffer.tokenizedLineForRow(6).foldable).toBe true - expect(tokenizedBuffer.tokenizedLineForRow(7).foldable).toBe false - expect(tokenizedBuffer.tokenizedLineForRow(8).foldable).toBe false + + foldableRows = tokenizedBuffer.foldableRowsForRowRange(6, 8) + expect(foldableRows.has(6)).toBe true + expect(foldableRows.has(7)).toBe false + expect(foldableRows.has(8)).toBe false describe "when the buffer is configured with the null grammar", -> it "uses the placeholder tokens and does not actually tokenize using the grammar", -> From 90c75fd6da268a1636278ce935285b5f298c66b7 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 17 Feb 2016 14:35:22 +0100 Subject: [PATCH 06/10] Delete specs testing previous behavior When emitting the `did-change` event, `updateFoldableStatus` used to extend the change region up and down to include all the lines that changed their foldability status because of a buffer change. I assume this was supposed to invalidate folds that *contained* the change whenever a line was edited in a way that affected also the previous or subsequent ones. That information, however, is not being used by `DisplayBuffer`, which does not alter existing folded regions when they become invalid. I believe the correct behavior should be to unfold the invalid region and recompute those screen lines. Nonetheless, it seems reasonable to me to keep the original (wrong) behavior and not address it in this branch, because it strays from the original intent of this refactoring. We should probably fix it once for all in another PR or when integrating/implementing `DisplayLayer`. --- spec/tokenized-buffer-spec.coffee | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/spec/tokenized-buffer-spec.coffee b/spec/tokenized-buffer-spec.coffee index 0f5c9c52d..ca64d2edb 100644 --- a/spec/tokenized-buffer-spec.coffee +++ b/spec/tokenized-buffer-spec.coffee @@ -202,8 +202,7 @@ describe "TokenizedBuffer", -> expect(tokenizedBuffer.firstInvalidRow()).toBe 3 advanceClock() - # we discover that row 2 starts a foldable region when line 3 gets tokenized - expect(changeHandler).toHaveBeenCalledWith(start: 2, end: 7, delta: 0) + expect(changeHandler).toHaveBeenCalledWith(start: 3, end: 7, delta: 0) expect(tokenizedBuffer.firstInvalidRow()).toBe 8 describe "when there is a buffer change surrounding an invalid row", -> @@ -253,7 +252,7 @@ describe "TokenizedBuffer", -> expect(changeHandler).toHaveBeenCalled() [event] = changeHandler.argsForCall[0] delete event.bufferChange - expect(event).toEqual(start: 1, end: 2, delta: 0) + expect(event).toEqual(start: 2, end: 2, delta: 0) changeHandler.reset() advanceClock() @@ -263,8 +262,7 @@ describe "TokenizedBuffer", -> expect(changeHandler).toHaveBeenCalled() [event] = changeHandler.argsForCall[0] delete event.bufferChange - # we discover that row 2 starts a foldable region when line 3 gets tokenized - expect(event).toEqual(start: 2, end: 5, delta: 0) + expect(event).toEqual(start: 3, end: 5, delta: 0) it "resumes highlighting with the state of the previous line", -> buffer.insert([0, 0], '/*') @@ -292,7 +290,7 @@ describe "TokenizedBuffer", -> expect(changeHandler).toHaveBeenCalled() [event] = changeHandler.argsForCall[0] delete event.bufferChange - expect(event).toEqual(start: 0, end: 3, delta: -2) # starts at 0 because foldable on row 0 becomes false + expect(event).toEqual(start: 1, end: 3, delta: -2) describe "when the change invalidates the tokenization of subsequent lines", -> it "schedules the invalidated lines to be tokenized in the background", -> @@ -305,7 +303,7 @@ describe "TokenizedBuffer", -> expect(changeHandler).toHaveBeenCalled() [event] = changeHandler.argsForCall[0] delete event.bufferChange - expect(event).toEqual(start: 1, end: 3, delta: -1) + expect(event).toEqual(start: 2, end: 3, delta: -1) changeHandler.reset() advanceClock() @@ -314,8 +312,7 @@ describe "TokenizedBuffer", -> expect(changeHandler).toHaveBeenCalled() [event] = changeHandler.argsForCall[0] delete event.bufferChange - # we discover that row 2 starts a foldable region when line 3 gets tokenized - expect(event).toEqual(start: 2, end: 4, delta: 0) + expect(event).toEqual(start: 3, end: 4, delta: 0) describe "when lines are both updated and inserted", -> it "updates tokens to reflect the change", -> @@ -339,7 +336,7 @@ describe "TokenizedBuffer", -> expect(changeHandler).toHaveBeenCalled() [event] = changeHandler.argsForCall[0] delete event.bufferChange - expect(event).toEqual(start: 0, end: 2, delta: 2) # starts at 0 because .foldable becomes false on row 0 + expect(event).toEqual(start: 1, end: 2, delta: 2) describe "when the change invalidates the tokenization of subsequent lines", -> it "schedules the invalidated lines to be tokenized in the background", -> @@ -350,7 +347,7 @@ describe "TokenizedBuffer", -> expect(changeHandler).toHaveBeenCalled() [event] = changeHandler.argsForCall[0] delete event.bufferChange - expect(event).toEqual(start: 1, end: 2, delta: 2) + expect(event).toEqual(start: 2, end: 2, delta: 2) expect(tokenizedBuffer.tokenizedLineForRow(2).tokens[0].scopes).toEqual ['source.js', 'comment.block.js', 'punctuation.definition.comment.js'] expect(tokenizedBuffer.tokenizedLineForRow(3).tokens[0].scopes).toEqual ['source.js', 'comment.block.js'] expect(tokenizedBuffer.tokenizedLineForRow(4).tokens[0].scopes).toEqual ['source.js', 'comment.block.js'] @@ -894,7 +891,7 @@ describe "TokenizedBuffer", -> buffer.setTextInRange([[7, 0], [8, 65]], ' ok') delete changeHandler.argsForCall[0][0].bufferChange - expect(changeHandler).toHaveBeenCalledWith(start: 4, end: 10, delta: -1) # starts at row 4 because it became foldable + expect(changeHandler).toHaveBeenCalledWith(start: 5, end: 10, delta: -1) expect(tokenizedBuffer.tokenizedLineForRow(5).indentLevel).toBe 2 expect(tokenizedBuffer.tokenizedLineForRow(6).indentLevel).toBe 2 From bea324eae92017e04f8ad0006a0d0da09f8f323e Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 17 Feb 2016 15:05:31 +0100 Subject: [PATCH 07/10] :fire: Use just `isFoldableAtBufferRow` --- spec/language-mode-spec.coffee | 11 ----- spec/tokenized-buffer-spec.coffee | 82 ++++++++++++++----------------- src/display-buffer.coffee | 4 +- src/text-editor-presenter.coffee | 9 +++- src/text-editor.coffee | 6 +-- src/tokenized-buffer.coffee | 9 ---- src/tokenized-line.coffee | 1 - 7 files changed, 47 insertions(+), 75 deletions(-) diff --git a/spec/language-mode-spec.coffee b/spec/language-mode-spec.coffee index 7ea4a1ae9..cd32e29c7 100644 --- a/spec/language-mode-spec.coffee +++ b/spec/language-mode-spec.coffee @@ -463,17 +463,6 @@ describe "LanguageMode", -> fold2 = editor.tokenizedLineForScreenRow(5).fold expect(fold2).toBeFalsy() - describe ".isFoldableAtBufferRow(bufferRow)", -> - it "returns true if the line starts a multi-line comment", -> - expect(languageMode.isFoldableAtBufferRow(1)).toBe true - expect(languageMode.isFoldableAtBufferRow(6)).toBe true - expect(languageMode.isFoldableAtBufferRow(17)).toBe false - - it "does not return true for a line in the middle of a comment that's followed by an indented line", -> - expect(languageMode.isFoldableAtBufferRow(7)).toBe false - editor.buffer.insert([8, 0], ' ') - expect(languageMode.isFoldableAtBufferRow(7)).toBe false - describe "css", -> beforeEach -> waitsForPromise -> diff --git a/spec/tokenized-buffer-spec.coffee b/spec/tokenized-buffer-spec.coffee index ca64d2edb..88c095f68 100644 --- a/spec/tokenized-buffer-spec.coffee +++ b/spec/tokenized-buffer-spec.coffee @@ -900,7 +900,7 @@ describe "TokenizedBuffer", -> expect(tokenizedBuffer.tokenizedLineForRow(9).indentLevel).toBe 2 expect(tokenizedBuffer.tokenizedLineForRow(10).indentLevel).toBe 2 # } - describe "::foldableRowsForRowRange(startRow, endRow)", -> + describe "::isFoldableAtRow(row)", -> changes = null beforeEach -> @@ -914,72 +914,64 @@ describe "TokenizedBuffer", -> fullyTokenize(tokenizedBuffer) it "includes the first line of multi-line comments", -> - foldableRows = tokenizedBuffer.foldableRowsForRowRange(0, 16) - expect(foldableRows.has(0)).toBe true - expect(foldableRows.has(1)).toBe false - expect(foldableRows.has(2)).toBe false - expect(foldableRows.has(3)).toBe true # because of indent - expect(foldableRows.has(13)).toBe true - expect(foldableRows.has(14)).toBe false - expect(foldableRows.has(15)).toBe false - expect(foldableRows.has(16)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(0)).toBe true + expect(tokenizedBuffer.isFoldableAtRow(1)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(2)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(3)).toBe true # because of indent + expect(tokenizedBuffer.isFoldableAtRow(13)).toBe true + expect(tokenizedBuffer.isFoldableAtRow(14)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(15)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(16)).toBe false buffer.insert([0, Infinity], '\n') - foldableRows = tokenizedBuffer.foldableRowsForRowRange(0, 3) - expect(foldableRows.has(0)).toBe false - expect(foldableRows.has(1)).toBe false - expect(foldableRows.has(2)).toBe true - expect(foldableRows.has(3)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(0)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(1)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(2)).toBe true + expect(tokenizedBuffer.isFoldableAtRow(3)).toBe false buffer.undo() - foldableRows = tokenizedBuffer.foldableRowsForRowRange(0, 3) - expect(foldableRows.has(0)).toBe true - expect(foldableRows.has(1)).toBe false - expect(foldableRows.has(2)).toBe false - expect(foldableRows.has(3)).toBe true # because of indent + expect(tokenizedBuffer.isFoldableAtRow(0)).toBe true + expect(tokenizedBuffer.isFoldableAtRow(1)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(2)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(3)).toBe true # because of indent it "includes non-comment lines that precede an increase in indentation", -> buffer.insert([2, 0], ' ') # commented lines preceding an indent aren't foldable - foldableRows = tokenizedBuffer.foldableRowsForRowRange(0, 8) - expect(foldableRows.has(1)).toBe false - expect(foldableRows.has(2)).toBe false - expect(foldableRows.has(3)).toBe true - expect(foldableRows.has(4)).toBe true - expect(foldableRows.has(5)).toBe false - expect(foldableRows.has(6)).toBe false - expect(foldableRows.has(7)).toBe true - expect(foldableRows.has(8)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(1)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(2)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(3)).toBe true + expect(tokenizedBuffer.isFoldableAtRow(4)).toBe true + expect(tokenizedBuffer.isFoldableAtRow(5)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(6)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(7)).toBe true + expect(tokenizedBuffer.isFoldableAtRow(8)).toBe false buffer.insert([7, 0], ' ') - foldableRows = tokenizedBuffer.foldableRowsForRowRange(6, 8) - expect(foldableRows.has(6)).toBe true - expect(foldableRows.has(7)).toBe false - expect(foldableRows.has(8)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(6)).toBe true + expect(tokenizedBuffer.isFoldableAtRow(7)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(8)).toBe false buffer.undo() - foldableRows = tokenizedBuffer.foldableRowsForRowRange(6, 8) - expect(foldableRows.has(6)).toBe false - expect(foldableRows.has(7)).toBe true - expect(foldableRows.has(8)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(6)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(7)).toBe true + expect(tokenizedBuffer.isFoldableAtRow(8)).toBe false buffer.insert([7, 0], " \n x\n") - foldableRows = tokenizedBuffer.foldableRowsForRowRange(6, 8) - expect(foldableRows.has(6)).toBe true - expect(foldableRows.has(7)).toBe false - expect(foldableRows.has(8)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(6)).toBe true + expect(tokenizedBuffer.isFoldableAtRow(7)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(8)).toBe false buffer.insert([9, 0], " ") - foldableRows = tokenizedBuffer.foldableRowsForRowRange(6, 8) - expect(foldableRows.has(6)).toBe true - expect(foldableRows.has(7)).toBe false - expect(foldableRows.has(8)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(6)).toBe true + expect(tokenizedBuffer.isFoldableAtRow(7)).toBe false + expect(tokenizedBuffer.isFoldableAtRow(8)).toBe false describe "when the buffer is configured with the null grammar", -> it "uses the placeholder tokens and does not actually tokenize using the grammar", -> diff --git a/src/display-buffer.coffee b/src/display-buffer.coffee index 8015f2df2..d01ad03c9 100644 --- a/src/display-buffer.coffee +++ b/src/display-buffer.coffee @@ -413,8 +413,8 @@ class DisplayBuffer extends Model isFoldedAtScreenRow: (screenRow) -> @largestFoldContainingBufferRow(@bufferRowForScreenRow(screenRow))? - foldableBufferRowsForBufferRowRange: (startRow, endRow) -> - @tokenizedBuffer.foldableRowsForRowRange(startRow, endRow) + isFoldableAtBufferRow: (row) -> + @tokenizedBuffer.isFoldableAtRow(row) # Destroys the fold with the given id destroyFoldWithId: (id) -> diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 48f269b9d..3266eea70 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -600,8 +600,14 @@ class TextEditorPresenter if endRow > startRow bufferRows = @model.bufferRowsForScreenRows(startRow, endRow - 1) - foldableBufferRows = @model.foldableBufferRowsForBufferRowRange(bufferRows[0], bufferRows[bufferRows.length - 1]) + previousBufferRow = -1 + foldable = false for bufferRow, i in bufferRows + # don't compute foldability more than once per buffer row + if previousBufferRow isnt bufferRow + foldable = @model.isFoldableAtBufferRow(bufferRow) + previousBufferRow = bufferRow + if bufferRow is lastBufferRow softWrapped = true else @@ -611,7 +617,6 @@ class TextEditorPresenter screenRow = startRow + i line = @model.tokenizedLineForScreenRow(screenRow) decorationClasses = @lineNumberDecorationClassesForRow(screenRow) - foldable = foldableBufferRows.has(bufferRow) blockDecorationsBeforeCurrentScreenRowHeight = @lineTopIndex.pixelPositionAfterBlocksForRow(screenRow) - @lineTopIndex.pixelPositionBeforeBlocksForRow(screenRow) blockDecorationsHeight = blockDecorationsBeforeCurrentScreenRowHeight if screenRow % @tileSize isnt 0 diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 6c80cfc01..c0a6f2057 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -2939,8 +2939,7 @@ class TextEditor extends Model # # Returns a {Boolean}. isFoldableAtBufferRow: (bufferRow) -> - # @languageMode.isFoldableAtBufferRow(bufferRow) - @foldableBufferRowsForBufferRowRange(bufferRow, bufferRow).has(bufferRow) + @displayBuffer.isFoldableAtBufferRow(bufferRow) # Extended: Determine whether the given row in screen coordinates is foldable. # @@ -2953,9 +2952,6 @@ class TextEditor extends Model bufferRow = @displayBuffer.bufferRowForScreenRow(screenRow) @isFoldableAtBufferRow(bufferRow) - foldableBufferRowsForBufferRowRange: (startRow, endRow) -> - @displayBuffer.foldableBufferRowsForBufferRowRange(startRow, endRow) - # Extended: Fold the given buffer row if it isn't currently folded, and unfold # it otherwise. toggleFoldAtBufferRow: (bufferRow) -> diff --git a/src/tokenized-buffer.coffee b/src/tokenized-buffer.coffee index 055e3fe47..5c62f9ecd 100644 --- a/src/tokenized-buffer.coffee +++ b/src/tokenized-buffer.coffee @@ -282,15 +282,6 @@ class TokenizedBuffer extends Model row - increment - foldableRowsForRowRange: (startRow, endRow) -> - scanStartRow = @buffer.previousNonBlankRow(startRow) ? startRow - scanStartRow-- while scanStartRow > 0 and @tokenizedLineForRow(scanStartRow).isComment() - scanEndRow = @buffer.nextNonBlankRow(endRow) ? endRow - foldableRows = new Set - for row in [scanStartRow..scanEndRow] by 1 when @isFoldableAtRow(row) - foldableRows.add(row) - foldableRows - isFoldableAtRow: (row) -> if @largeFileMode false diff --git a/src/tokenized-line.coffee b/src/tokenized-line.coffee index c97a621ac..372f488a6 100644 --- a/src/tokenized-line.coffee +++ b/src/tokenized-line.coffee @@ -33,7 +33,6 @@ class TokenizedLine endOfLineInvisibles: null lineIsWhitespaceOnly: false firstNonWhitespaceIndex: 0 - foldable: false constructor: (properties) -> @id = idCounter++ From 2a35d19dd35bd3b0d16a6da193a35f954b68d5fa Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 17 Feb 2016 16:00:35 +0100 Subject: [PATCH 08/10] :racehorse: Memoize TokenizedLine.prototype.isComment --- src/tokenized-line.coffee | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tokenized-line.coffee b/src/tokenized-line.coffee index 372f488a6..bf6a6dd2b 100644 --- a/src/tokenized-line.coffee +++ b/src/tokenized-line.coffee @@ -491,15 +491,20 @@ class TokenizedLine @endOfLineInvisibles.push(eol) if eol isComment: -> + return @isCommentLine if @isCommentLine? + + @isCommentLine = false iterator = @getTokenIterator() while iterator.next() scopes = iterator.getScopes() continue if scopes.length is 1 continue unless NonWhitespaceRegex.test(iterator.getText()) for scope in scopes - return true if CommentScopeRegex.test(scope) + if CommentScopeRegex.test(scope) + @isCommentLine = true + break break - false + @isCommentLine isOnlyWhitespace: -> @lineIsWhitespaceOnly From 68bf2f8dc7c3d69439aaac1cc4ac8f0ae27e7133 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 17 Feb 2016 17:20:54 +0100 Subject: [PATCH 09/10] :green_heart: Fix unrelated failing spec --- spec/text-editor-component-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/text-editor-component-spec.js b/spec/text-editor-component-spec.js index 08da07dd8..8aaccbd6c 100644 --- a/spec/text-editor-component-spec.js +++ b/spec/text-editor-component-spec.js @@ -544,7 +544,7 @@ describe('TextEditorComponent', function () { editor.setSoftWrapped(true) await nextViewUpdatePromise() - componentNode.style.width = 16 * charWidth + wrapperNode.getVerticalScrollbarWidth() + 'px' + componentNode.style.width = 17 * charWidth + wrapperNode.getVerticalScrollbarWidth() + 'px' component.measureDimensions() await nextViewUpdatePromise() }) From d6132888faf4fbcc2a7a8ebbee7b89d122140938 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 18 Feb 2016 14:18:27 +0100 Subject: [PATCH 10/10] :green_heart: Attempt to fix specs --- spec/text-editor-component-spec.js | 2 +- src/text-editor-presenter.coffee | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/spec/text-editor-component-spec.js b/spec/text-editor-component-spec.js index 8aaccbd6c..08da07dd8 100644 --- a/spec/text-editor-component-spec.js +++ b/spec/text-editor-component-spec.js @@ -544,7 +544,7 @@ describe('TextEditorComponent', function () { editor.setSoftWrapped(true) await nextViewUpdatePromise() - componentNode.style.width = 17 * charWidth + wrapperNode.getVerticalScrollbarWidth() + 'px' + componentNode.style.width = 16 * charWidth + wrapperNode.getVerticalScrollbarWidth() + 'px' component.measureDimensions() await nextViewUpdatePromise() }) diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 3266eea70..a3504caa8 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -90,7 +90,7 @@ class TextEditorPresenter @updateLineDecorations() @updateBlockDecorations() - @updateTilesState(true) + @updateTilesState() @updating = false @state @@ -112,7 +112,7 @@ class TextEditorPresenter @updateHiddenInputState() @updateContentState() @updateHighlightDecorations() if @shouldUpdateDecorations - @updateTilesState(false) + @updateTilesState() @updateCursorsState() @updateOverlaysState() @updateLineNumberGutterState() @@ -327,7 +327,7 @@ class TextEditorPresenter clearScreenRowsToMeasure: -> @screenRowsToMeasure = [] - updateTilesState: (updateLinesState) -> + updateTilesState: -> return unless @startRow? and @endRow? and @lineHeight? screenRows = @getScreenRows() @@ -367,9 +367,8 @@ class TextEditorPresenter gutterTile.display = "block" gutterTile.zIndex = zIndex - if updateLinesState - @updateLinesState(tile, rowsWithinTile) - @updateLineNumbersState(gutterTile, rowsWithinTile) + @updateLinesState(tile, rowsWithinTile) + @updateLineNumbersState(gutterTile, rowsWithinTile) visibleTiles[tileStartRow] = true zIndex++