mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-21 16:08:24 +03:00
🐛 Correctly display highlight regions
This commit is contained in:
parent
b20394e323
commit
b3c9a9a77d
@ -1270,7 +1270,6 @@ class TextEditorPresenter
|
||||
|
||||
flash = decoration.consumeNextFlash()
|
||||
|
||||
|
||||
startTile = @tileForRow(range.start.row)
|
||||
endTile = @tileForRow(range.end.row)
|
||||
|
||||
@ -1290,8 +1289,6 @@ class TextEditorPresenter
|
||||
if endRow is range.end.row
|
||||
tileRange.end.column = range.end.column
|
||||
|
||||
console.log "Range for tile #{currentTile}: #{tileRange.toString()}"
|
||||
|
||||
highlightState = tileState.highlights[decoration.id] ?= {
|
||||
flashCount: 0
|
||||
flashDuration: null
|
||||
@ -1317,20 +1314,25 @@ class TextEditorPresenter
|
||||
|
||||
buildHighlightRegions: (tileStartRow, screenRange) ->
|
||||
lineHeightInPixels = @lineHeight
|
||||
startPixelPosition = @pixelPositionForScreenPositionInTile(tileStartRow, screenRange.start, true)
|
||||
startPixelPosition = @pixelPositionForScreenPositionInTile(tileStartRow, screenRange.start, false)
|
||||
endPixelPosition = @pixelPositionForScreenPositionInTile(tileStartRow, screenRange.end, true)
|
||||
spannedRows = screenRange.end.row - screenRange.start.row + 1
|
||||
|
||||
regions = []
|
||||
|
||||
if spannedRows is 1
|
||||
[
|
||||
region =
|
||||
top: startPixelPosition.top
|
||||
height: lineHeightInPixels
|
||||
left: startPixelPosition.left
|
||||
width: endPixelPosition.left - startPixelPosition.left
|
||||
]
|
||||
else
|
||||
regions = []
|
||||
|
||||
if screenRange.end.column is Infinity
|
||||
region.right = 0
|
||||
else
|
||||
region.width = endPixelPosition.left - startPixelPosition.left
|
||||
|
||||
regions.push(region)
|
||||
else
|
||||
# First row, extending from selection start to the right side of screen
|
||||
regions.push(
|
||||
top: startPixelPosition.top
|
||||
@ -1350,14 +1352,19 @@ class TextEditorPresenter
|
||||
|
||||
# Last row, extending from left side of screen to selection end
|
||||
if screenRange.end.column > 0
|
||||
regions.push(
|
||||
region =
|
||||
top: endPixelPosition.top
|
||||
height: lineHeightInPixels
|
||||
left: 0
|
||||
width: endPixelPosition.left
|
||||
)
|
||||
|
||||
regions
|
||||
if screenRange.end.column is Infinity
|
||||
region.right = 0
|
||||
else
|
||||
region.width = endPixelPosition.left
|
||||
|
||||
regions.push(region)
|
||||
|
||||
regions
|
||||
|
||||
setOverlayDimensions: (decorationId, itemWidth, itemHeight, contentMargin) ->
|
||||
@overlayDimensions[decorationId] ?= {}
|
||||
|
Loading…
Reference in New Issue
Block a user