mirror of
https://github.com/atom/atom.git
synced 2026-02-09 06:05:11 -05:00
WIP: Start on LineWrapper.displayPositionFromBufferPosition
It takes a row, column from the buffer and converts it to coordinates that account for line wrapping.
This commit is contained in:
@@ -35,6 +35,7 @@ class LineWrapper
|
||||
|
||||
currentSegment = []
|
||||
currentSegment.lastIndex = 0
|
||||
currentSegment.textLength = 0
|
||||
segments = [currentSegment]
|
||||
nextBreak = breakIndices.shift()
|
||||
for token in @highlighter.tokensForRow(row)
|
||||
@@ -50,3 +51,17 @@ class LineWrapper
|
||||
currentSegment.textLength += token.value.length
|
||||
|
||||
segments
|
||||
|
||||
displayPositionFromBufferPosition: (bufferPosition) ->
|
||||
row = 0
|
||||
for segments in @lines[0...bufferPosition.row]
|
||||
row += segments.length
|
||||
|
||||
column = bufferPosition.column
|
||||
for segment in @lines[bufferPosition.row]
|
||||
break if segment.lastIndex > bufferPosition.column
|
||||
column -= segment.textLength
|
||||
row++
|
||||
|
||||
{ row, column }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user