mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Revert "🐎 Faster line number calculation"
This reverts commit e04aef0af3.
This commit is contained in:
@@ -143,6 +143,16 @@ describe "DisplayBuffer", ->
|
||||
expect(displayBuffer.tokenizedLineForScreenRow(3).tokens[1].isHardTab).toBeTruthy()
|
||||
|
||||
describe "when a line is wrapped", ->
|
||||
it "marks it as soft-wrapped", ->
|
||||
displayBuffer.setEditorWidthInChars(7)
|
||||
|
||||
expect(displayBuffer.tokenizedLineForScreenRow(0).softWrapped).toBeFalsy()
|
||||
expect(displayBuffer.tokenizedLineForScreenRow(1).softWrapped).toBeTruthy()
|
||||
expect(displayBuffer.tokenizedLineForScreenRow(2).softWrapped).toBeTruthy()
|
||||
expect(displayBuffer.tokenizedLineForScreenRow(3).softWrapped).toBeTruthy()
|
||||
expect(displayBuffer.tokenizedLineForScreenRow(4).softWrapped).toBeTruthy()
|
||||
expect(displayBuffer.tokenizedLineForScreenRow(5).softWrapped).toBeFalsy()
|
||||
|
||||
it "breaks soft-wrap indentation into a token for each indentation level to support indent guides", ->
|
||||
tokenizedLine = displayBuffer.tokenizedLineForScreenRow(4)
|
||||
|
||||
|
||||
@@ -657,33 +657,15 @@ class TextEditorPresenter
|
||||
tileState.lineNumbers ?= {}
|
||||
visibleLineNumberIds = {}
|
||||
|
||||
# rows are reversed
|
||||
startRow = screenRows[screenRows.length - 1]
|
||||
endRow = screenRows[0]
|
||||
for screenRow in screenRows
|
||||
line = @model.tokenizedLineForScreenRow(screenRow)
|
||||
bufferRow = @model.bufferRowForScreenRow(screenRow)
|
||||
softWrapped = line.softWrapped
|
||||
decorationClasses = @lineNumberDecorationClassesForRow(screenRow)
|
||||
foldable = @model.isFoldableAtScreenRow(screenRow)
|
||||
|
||||
if startRow > 0
|
||||
rowBeforeStartRow = startRow - 1
|
||||
lastBufferRow = @model.bufferRowForScreenRow(rowBeforeStartRow)
|
||||
else
|
||||
lastBufferRow = null
|
||||
|
||||
if endRow > startRow
|
||||
bufferRows = @model.bufferRowsForScreenRows(startRow, endRow)
|
||||
for bufferRow, i in bufferRows
|
||||
if bufferRow is lastBufferRow
|
||||
softWrapped = true
|
||||
else
|
||||
lastBufferRow = bufferRow
|
||||
softWrapped = false
|
||||
|
||||
screenRow = startRow + i
|
||||
top = (screenRow - startRow) * @lineHeight
|
||||
decorationClasses = @lineNumberDecorationClassesForRow(screenRow)
|
||||
foldable = @model.isFoldableAtScreenRow(screenRow)
|
||||
id = @model.tokenizedLineForScreenRow(screenRow).id
|
||||
|
||||
tileState.lineNumbers[id] = {screenRow, bufferRow, softWrapped, top, decorationClasses, foldable}
|
||||
visibleLineNumberIds[id] = true
|
||||
tileState.lineNumbers[line.id] = {screenRow, bufferRow, softWrapped, decorationClasses, foldable}
|
||||
visibleLineNumberIds[line.id] = true
|
||||
|
||||
for lineId of tileState.lineNumbers
|
||||
delete tileState.lineNumbers[lineId] unless visibleLineNumberIds[lineId]
|
||||
|
||||
@@ -34,6 +34,7 @@ class TokenizedLine
|
||||
lineIsWhitespaceOnly: false
|
||||
firstNonWhitespaceIndex: 0
|
||||
foldable: false
|
||||
softWrapped: false
|
||||
|
||||
constructor: (properties) ->
|
||||
@id = idCounter++
|
||||
@@ -420,6 +421,7 @@ class TokenizedLine
|
||||
leftFragment.tabLength = @tabLength
|
||||
leftFragment.firstNonWhitespaceIndex = Math.min(column, @firstNonWhitespaceIndex)
|
||||
leftFragment.firstTrailingWhitespaceIndex = Math.min(column, @firstTrailingWhitespaceIndex)
|
||||
leftFragment.softWrapped = @softWrapped
|
||||
|
||||
rightFragment = new TokenizedLine
|
||||
rightFragment.tokenIterator = @tokenIterator
|
||||
@@ -437,6 +439,7 @@ class TokenizedLine
|
||||
rightFragment.endOfLineInvisibles = @endOfLineInvisibles
|
||||
rightFragment.firstNonWhitespaceIndex = Math.max(softWrapIndent, @firstNonWhitespaceIndex - column + softWrapIndent)
|
||||
rightFragment.firstTrailingWhitespaceIndex = Math.max(softWrapIndent, @firstTrailingWhitespaceIndex - column + softWrapIndent)
|
||||
rightFragment.softWrapped = true
|
||||
|
||||
[leftFragment, rightFragment]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user