mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
@@ -1704,6 +1704,18 @@ describe "TextEditorPresenter", ->
|
||||
|
||||
expectUndefinedStateForHighlight(presenter, highlight)
|
||||
|
||||
it "does not include highlights that end before the first visible row", ->
|
||||
editor.setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.")
|
||||
editor.setSoftWrapped(true)
|
||||
editor.setWidth(100, true)
|
||||
editor.setDefaultCharWidth(10)
|
||||
|
||||
marker = editor.markBufferRange([[0, 0], [0, 4]], invalidate: 'never')
|
||||
highlight = editor.decorateMarker(marker, type: 'highlight', class: 'a')
|
||||
presenter = buildPresenter(explicitHeight: 30, scrollTop: 10, tileSize: 2)
|
||||
|
||||
expect(stateForHighlightInTile(presenter, highlight, 0)).toBeUndefined()
|
||||
|
||||
it "updates when ::scrollTop changes", ->
|
||||
editor.setSelectedBufferRanges([
|
||||
[[6, 2], [6, 4]],
|
||||
|
||||
@@ -1244,14 +1244,7 @@ class TextEditorPresenter
|
||||
updateHighlightState: (decorationId, properties, screenRange) ->
|
||||
return unless @startRow? and @endRow? and @lineHeight? and @hasPixelPositionRequirements()
|
||||
|
||||
return if screenRange.isEmpty()
|
||||
|
||||
if screenRange.start.row < @startRow
|
||||
screenRange.start.row = @startRow
|
||||
screenRange.start.column = 0
|
||||
if screenRange.end.row >= @endRow
|
||||
screenRange.end.row = @endRow
|
||||
screenRange.end.column = 0
|
||||
@constrainRangeToVisibleRowRange(screenRange)
|
||||
|
||||
return if screenRange.isEmpty()
|
||||
|
||||
@@ -1281,6 +1274,23 @@ class TextEditorPresenter
|
||||
|
||||
true
|
||||
|
||||
constrainRangeToVisibleRowRange: (screenRange) ->
|
||||
if screenRange.start.row < @startRow
|
||||
screenRange.start.row = @startRow
|
||||
screenRange.start.column = 0
|
||||
|
||||
if screenRange.end.row < @startRow
|
||||
screenRange.end.row = @startRow
|
||||
screenRange.end.column = 0
|
||||
|
||||
if screenRange.start.row >= @endRow
|
||||
screenRange.start.row = @endRow
|
||||
screenRange.start.column = 0
|
||||
|
||||
if screenRange.end.row >= @endRow
|
||||
screenRange.end.row = @endRow
|
||||
screenRange.end.column = 0
|
||||
|
||||
repositionRegionWithinTile: (region, tileStartRow) ->
|
||||
region.top += @scrollTop - tileStartRow * @lineHeight
|
||||
region.left += @scrollLeft
|
||||
|
||||
Reference in New Issue
Block a user