mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Add 'onlyHead' option for decorations
It only decorates the head position of the decoration's marker.
This commit is contained in:
@@ -324,7 +324,7 @@ describe "EditorComponent", ->
|
||||
editor.addDecorationForMarker(marker, decoration)
|
||||
runSetImmediateCallbacks()
|
||||
|
||||
it "does not render off-screen lines with line number classes until they are with in the rendered row range", ->
|
||||
it "does not render off-screen lines with decoration classes until they are with in the rendered row range", ->
|
||||
node.style.height = 4.5 * lineHeightInPixels + 'px'
|
||||
component.measureScrollView()
|
||||
runSetImmediateCallbacks()
|
||||
@@ -348,6 +348,14 @@ describe "EditorComponent", ->
|
||||
expect(lineHasClass(3, 'someclass')).toBe true
|
||||
expect(lineHasClass(4, 'someclass')).toBe false
|
||||
|
||||
it "only renders 'onlyHead' decorations on lines containing the marker's head", ->
|
||||
editor.addDecorationForMarker(marker, type: 'line', class: 'only-head', onlyHead: true)
|
||||
runSetImmediateCallbacks()
|
||||
expect(lineHasClass(1, 'only-head')).toBe false
|
||||
expect(lineHasClass(2, 'only-head')).toBe false
|
||||
expect(lineHasClass(3, 'only-head')).toBe true
|
||||
expect(lineHasClass(4, 'only-head')).toBe false
|
||||
|
||||
it "removes line classes when a decoration's marker is invalidated", ->
|
||||
editor.getBuffer().insert([3, 2], 'n')
|
||||
runSetImmediateCallbacks()
|
||||
|
||||
@@ -262,14 +262,17 @@ EditorComponent = React.createClass
|
||||
for markerId, decorations of decorationsByMarkerId
|
||||
marker = editor.getMarker(markerId)
|
||||
screenRange = null
|
||||
headScreenRow = null
|
||||
if marker.isValid()
|
||||
for decoration in decorations
|
||||
if editor.decorationMatchesType(decoration, 'gutter') or editor.decorationMatchesType(decoration, 'line')
|
||||
screenRange ?= marker.getScreenRange()
|
||||
headScreenRow ?= marker.getHeadScreenPosition().row
|
||||
startRow = screenRange.start.row
|
||||
endRow = screenRange.end.row
|
||||
endRow-- if not screenRange.isEmpty() and screenRange.end.column == 0
|
||||
for screenRow in [startRow..endRow]
|
||||
continue if decoration.onlyHead and screenRow isnt headScreenRow
|
||||
decorationsByScreenRow[screenRow] ?= []
|
||||
decorationsByScreenRow[screenRow].push decoration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user