mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 18:24:09 +03:00
Don't render empty highlights
This commit is contained in:
parent
4832d36ac1
commit
99ba20ae0d
@ -736,12 +736,12 @@ describe "EditorComponent", ->
|
||||
expect(region3Rect.left).toBe scrollViewClientLeft + 0
|
||||
expect(region3Rect.width).toBe 10 * charWidth
|
||||
|
||||
it "does not render empty selections unless they are the first selection (to prevent a Chromium rendering artifact caused by removing it)", ->
|
||||
it "does not render empty selections", ->
|
||||
editor.addSelectionForBufferRange([[2, 2], [2, 2]])
|
||||
expect(editor.getSelection(0).isEmpty()).toBe true
|
||||
expect(editor.getSelection(1).isEmpty()).toBe true
|
||||
|
||||
expect(node.querySelectorAll('.selection').length).toBe 1
|
||||
expect(node.querySelectorAll('.selection').length).toBe 0
|
||||
|
||||
it "updates selections when the line height changes", ->
|
||||
editor.setSelectedBufferRange([[1, 6], [1, 10]])
|
||||
@ -818,8 +818,7 @@ describe "EditorComponent", ->
|
||||
|
||||
waitsFor -> not component.decorationChangedImmediate?
|
||||
runs ->
|
||||
regionStyle = node.querySelector('.test-highlight .region').style
|
||||
expect(regionStyle.width).toBe '0px'
|
||||
expect(node.querySelectorAll('.test-highlight').length).toBe 0
|
||||
|
||||
it "moves rendered highlights when the marker moves", ->
|
||||
regionStyle = node.querySelector('.test-highlight .region').style
|
||||
|
@ -233,15 +233,17 @@ EditorComponent = React.createClass
|
||||
decorationsByScreenRow
|
||||
|
||||
getHighlightDecorations: (decorationsByMarkerId) ->
|
||||
{editor} = @props
|
||||
filteredDecorations = {}
|
||||
for id, decorations of decorationsByMarkerId
|
||||
for decoration in decorations
|
||||
if decoration.isValid() and decoration.isType('highlight')
|
||||
# Using decoration.toObject() for comparability sake. This effectively
|
||||
# caches the current state of the decoration object (importantly, the range).
|
||||
# We need to cache the range because the Decoration's marker's range changes.
|
||||
filteredDecorations[id] ?= []
|
||||
filteredDecorations[id].push decoration.toObject()
|
||||
for markerId, decorations of decorationsByMarkerId
|
||||
unless editor.getMarker(markerId).getScreenRange().isEmpty()
|
||||
for decoration in decorations
|
||||
if decoration.isValid() and decoration.isType('highlight')
|
||||
# Using decoration.toObject() for comparability sake. This effectively
|
||||
# caches the current state of the decoration object (importantly, the range).
|
||||
# We need to cache the range because the Decoration's marker's range changes.
|
||||
filteredDecorations[markerId] ?= []
|
||||
filteredDecorations[markerId].push decoration.toObject()
|
||||
filteredDecorations
|
||||
|
||||
observeEditor: ->
|
||||
|
Loading…
Reference in New Issue
Block a user