💚 Use tokenizedLine.id to refer to lines

This commit is contained in:
Antonio Scandurra
2015-09-17 11:10:32 +02:00
parent 751f5920b4
commit 42e58f1dd3
4 changed files with 16 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ class MockLineNodesProvider
setDefaultFont: (font) -> @defaultFont = font
lineNodeForScreenRow: (screenRow) ->
lineNodeForLineIdAndScreenRow: (id, screenRow) ->
lineNode = document.createElement("div")
lineNode.style.whiteSpace = "pre"
lineState = @editor.tokenizedLineForScreenRow(screenRow)

View File

@@ -320,6 +320,9 @@ class LinesTileComponent
lineNodeForScreenRow: (screenRow) ->
@lineNodesByLineId[@lineIdsByScreenRow[screenRow]]
lineNodeForLineId: (lineId) ->
@lineNodesByLineId[lineId]
measureCharactersInNewLines: ->
for id, lineState of @oldTileState.lines
unless @measuredLines.has(id)

View File

@@ -22,10 +22,14 @@ class LinesYardstick
{top, left}
leftPixelPositionForScreenPosition: (row, column) ->
lineNode = @lineNodesProvider.lineNodeForScreenRow(row)
tokenizedLine = @model.tokenizedLineForScreenRow(row)
return 0 unless tokenizedLine?
lineNode =
@lineNodesProvider.lineNodeForLineIdAndScreenRow(tokenizedLine.id, row)
return 0 unless lineNode?
tokenizedLine = @model.tokenizedLineForScreenRow(row)
iterator = document.createNodeIterator(lineNode, NodeFilter.SHOW_TEXT, AcceptFilter)
charIndex = 0

View File

@@ -743,6 +743,12 @@ class TextEditorComponent
consolidateSelections: (e) ->
e.abortKeyBinding() unless @editor.consolidateSelections()
lineNodeForLineIdAndScreenRow: (lineId, screenRow) ->
tileRow = @presenter.tileForRow(screenRow)
tileComponent = @linesComponent.getComponentForTile(tileRow)
tileComponent?.lineNodeForLineId(lineId)
lineNodeForScreenRow: (screenRow) ->
tileRow = @presenter.tileForRow(screenRow)
tileComponent = @linesComponent.getComponentForTile(tileRow)