mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
💚 Fix TextEditorPresenter specs
...so that they play nicely with LinesYardstick
This commit is contained in:
@@ -38,6 +38,8 @@ class TextEditorPresenter
|
||||
@startBlinkingCursors() if @focused
|
||||
@updating = false
|
||||
|
||||
setLinesYardstick: (@linesYardstick) ->
|
||||
|
||||
destroy: ->
|
||||
@disposables.dispose()
|
||||
|
||||
@@ -1057,42 +1059,12 @@ class TextEditorPresenter
|
||||
hasPixelPositionRequirements: ->
|
||||
@lineHeight? and @baseCharacterWidth?
|
||||
|
||||
pixelPositionForScreenPosition: (screenPosition, clip=true) ->
|
||||
screenPosition = Point.fromObject(screenPosition)
|
||||
screenPosition = @model.clipScreenPosition(screenPosition) if clip
|
||||
|
||||
targetRow = screenPosition.row
|
||||
targetColumn = screenPosition.column
|
||||
baseCharacterWidth = @baseCharacterWidth
|
||||
|
||||
top = targetRow * @lineHeight
|
||||
left = 0
|
||||
column = 0
|
||||
|
||||
iterator = @model.tokenizedLineForScreenRow(targetRow).getTokenIterator()
|
||||
while iterator.next()
|
||||
characterWidths = @getScopedCharacterWidths(iterator.getScopes())
|
||||
|
||||
valueIndex = 0
|
||||
text = iterator.getText()
|
||||
while valueIndex < text.length
|
||||
if iterator.isPairedCharacter()
|
||||
char = text
|
||||
charLength = 2
|
||||
valueIndex += 2
|
||||
else
|
||||
char = text[valueIndex]
|
||||
charLength = 1
|
||||
valueIndex++
|
||||
|
||||
break if column is targetColumn
|
||||
|
||||
left += characterWidths[char] ? baseCharacterWidth unless char is '\0'
|
||||
column += charLength
|
||||
|
||||
top -= @scrollTop
|
||||
left -= @scrollLeft
|
||||
{top, left}
|
||||
pixelPositionForScreenPosition: (screenPosition, clip) ->
|
||||
pixelPosition =
|
||||
@linesYardstick.pixelPositionForScreenPosition(screenPosition, clip)
|
||||
pixelPosition.top -= @scrollTop
|
||||
pixelPosition.left -= @scrollLeft
|
||||
pixelPosition
|
||||
|
||||
hasPixelRectRequirements: ->
|
||||
@hasPixelPositionRequirements() and @scrollWidth?
|
||||
|
||||
Reference in New Issue
Block a user