mirror of
https://github.com/atom/atom.git
synced 2026-02-08 05:35:04 -05:00
Replace tokens with tagCodes in DisplayLayer.prototype.getScreenLines
This commit is contained in:
@@ -253,26 +253,26 @@ class LinesTileComponent
|
||||
@currentLineTextNodes.push(textNode)
|
||||
|
||||
setLineInnerNodes: (id, lineNode) ->
|
||||
{tokens} = @newTileState.lines[id]
|
||||
{lineText, tagCodes} = @newTileState.lines[id]
|
||||
|
||||
lineLength = 0
|
||||
startIndex = 0
|
||||
openScopeNode = lineNode
|
||||
for token in tokens when token.text.length > 0
|
||||
{closeTags, openTags, text} = token
|
||||
|
||||
for scope in closeTags
|
||||
for tagCode in tagCodes when tagCode isnt 0
|
||||
if @presenter.isCloseTagCode(tagCode)
|
||||
openScopeNode = openScopeNode.parentElement
|
||||
|
||||
for scope in openTags
|
||||
else if @presenter.isOpenTagCode(tagCode)
|
||||
scope = @presenter.tagForCode(tagCode)
|
||||
newScopeNode = @domElementPool.buildElement("span", scope.replace(/\.+/g, ' '))
|
||||
openScopeNode.appendChild(newScopeNode)
|
||||
openScopeNode = newScopeNode
|
||||
else
|
||||
textNode = @domElementPool.buildText(lineText.substr(startIndex, tagCode).replace(/\s/g, NBSPCharacter))
|
||||
startIndex += tagCode
|
||||
openScopeNode.appendChild(textNode)
|
||||
@currentLineTextNodes.push(textNode)
|
||||
|
||||
lineLength += text.length
|
||||
textNode = @domElementPool.buildText(text.replace(/\s/g, NBSPCharacter))
|
||||
openScopeNode.appendChild(textNode)
|
||||
@currentLineTextNodes.push(textNode)
|
||||
|
||||
if lineLength is 0
|
||||
if startIndex is 0
|
||||
textNode = @domElementPool.buildText(NBSPCharacter)
|
||||
lineNode.appendChild(textNode)
|
||||
@currentLineTextNodes.push(textNode)
|
||||
|
||||
@@ -436,7 +436,8 @@ class TextEditorPresenter
|
||||
else
|
||||
tileState.lines[line.id] =
|
||||
screenRow: screenRow
|
||||
tokens: line.tokens
|
||||
lineText: line.lineText
|
||||
tagCodes: line.tagCodes
|
||||
decorationClasses: @lineDecorationClassesForRow(screenRow)
|
||||
precedingBlockDecorations: precedingBlockDecorations
|
||||
followingBlockDecorations: followingBlockDecorations
|
||||
@@ -1548,3 +1549,12 @@ class TextEditorPresenter
|
||||
|
||||
isRowVisible: (row) ->
|
||||
@startRow <= row < @endRow
|
||||
|
||||
isOpenTagCode: (tagCode) ->
|
||||
@displayLayer.isOpenTagCode(tagCode)
|
||||
|
||||
isCloseTagCode: (tagCode) ->
|
||||
@displayLayer.isCloseTagCode(tagCode)
|
||||
|
||||
tagForCode: (tagCode) ->
|
||||
@displayLayer.tagForCode(tagCode)
|
||||
|
||||
Reference in New Issue
Block a user