mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05: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'
|
||||
|
||||
@@ -218,6 +218,7 @@ class Editor extends Model
|
||||
@subscribe @displayBuffer, "decoration-added", (args...) => @emit 'decoration-added', args...
|
||||
@subscribe @displayBuffer, "decoration-removed", (args...) => @emit 'decoration-removed', args...
|
||||
@subscribe @displayBuffer, "decoration-changed", (args...) => @emit 'decoration-changed', args...
|
||||
@subscribe @displayBuffer, "decoration-updated", (args...) => @emit 'decoration-updated', args...
|
||||
@subscribe @displayBuffer, "character-widths-changed", (changeCount) => @emit 'character-widths-changed', changeCount
|
||||
|
||||
getViewClass: ->
|
||||
@@ -1111,6 +1112,10 @@ class Editor extends Model
|
||||
addDecorationForMarker: (marker, decoration) ->
|
||||
@displayBuffer.addDecorationForMarker(marker, decoration)
|
||||
|
||||
#
|
||||
updateDecorationForMarker: (marker, decorationPattern, newDecoration) ->
|
||||
@displayBuffer.updateDecorationForMarker(marker, decorationPattern, newDecoration)
|
||||
|
||||
# Public: Removes all decorations associated with a {Marker} that match a
|
||||
# `decorationPattern` and stop tracking the {Marker}.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user