mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add updateDecorationForMarker()
This commit is contained in:
@@ -795,6 +795,21 @@ class DisplayBuffer extends Model
|
||||
@decorationsByMarkerId[marker.id].push(decoration)
|
||||
@emit 'decoration-added', marker, decoration
|
||||
|
||||
updateDecorationForMarker: (marker, decorationPattern, newDecoration) ->
|
||||
unless marker?
|
||||
console.warn 'A null marker cannot be decorated'
|
||||
return
|
||||
|
||||
marker = @getMarker(marker.id)
|
||||
return unless decorations = @decorationsByMarkerId[marker.id]
|
||||
|
||||
for decoration, i in decorations
|
||||
if @decorationMatchesPattern(decoration, decorationPattern) and not _.isEqual(decoration, newDecoration)
|
||||
decorations[i] = newDecoration
|
||||
@emit 'decoration-updated', marker, decoration, newDecoration
|
||||
|
||||
return
|
||||
|
||||
removeDecorationForMarker: (marker, decorationPattern) ->
|
||||
unless marker?
|
||||
console.warn 'A decoration cannot be removed from a null marker'
|
||||
|
||||
Reference in New Issue
Block a user