mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add 'onlyEmpty' and 'onlyNonEmpty' decoration options
This commit is contained in:
@@ -356,6 +356,28 @@ describe "EditorComponent", ->
|
||||
expect(lineHasClass(3, 'only-head')).toBe true
|
||||
expect(lineHasClass(4, 'only-head')).toBe false
|
||||
|
||||
it "only renders 'onlyEmpty' decorations on lines for which the marker is empty", ->
|
||||
editor.addDecorationForMarker(marker, type: 'line', class: 'only-empty', onlyEmpty: true)
|
||||
runSetImmediateCallbacks()
|
||||
expect(lineHasClass(2, 'only-empty')).toBe false
|
||||
expect(lineHasClass(3, 'only-empty')).toBe false
|
||||
|
||||
marker.clearTail()
|
||||
runSetImmediateCallbacks()
|
||||
expect(lineHasClass(2, 'only-empty')).toBe false
|
||||
expect(lineHasClass(3, 'only-empty')).toBe true
|
||||
|
||||
it "only renders 'onlyNonEmpty' decorations on lines for which the marker is non-empty", ->
|
||||
editor.addDecorationForMarker(marker, type: 'line', class: 'only-non-empty', onlyNonEmpty: true)
|
||||
runSetImmediateCallbacks()
|
||||
expect(lineHasClass(2, 'only-non-empty')).toBe true
|
||||
expect(lineHasClass(3, 'only-non-empty')).toBe true
|
||||
|
||||
marker.clearTail()
|
||||
runSetImmediateCallbacks()
|
||||
expect(lineHasClass(2, 'only-non-empty')).toBe false
|
||||
expect(lineHasClass(3, 'only-non-empty')).toBe false
|
||||
|
||||
it "removes line classes when a decoration's marker is invalidated", ->
|
||||
editor.getBuffer().insert([3, 2], 'n')
|
||||
runSetImmediateCallbacks()
|
||||
|
||||
@@ -273,6 +273,11 @@ EditorComponent = React.createClass
|
||||
endRow-- if not screenRange.isEmpty() and screenRange.end.column == 0
|
||||
for screenRow in [startRow..endRow]
|
||||
continue if decoration.onlyHead and screenRow isnt headScreenRow
|
||||
if screenRange.isEmpty()
|
||||
continue if decoration.onlyNonEmpty
|
||||
else
|
||||
continue if decoration.onlyEmpty
|
||||
|
||||
decorationsByScreenRow[screenRow] ?= []
|
||||
decorationsByScreenRow[screenRow].push decoration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user