mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
[Gutter] Clear custom gutter decoration state objects instead of reassigning to new objects
This commit is contained in:
@@ -473,12 +473,20 @@ class TextEditorPresenter
|
||||
updateCustomGutterDecorationState: ->
|
||||
return unless @startRow? and @endRow? and @lineHeight?
|
||||
|
||||
@customGutterDecorations = {}
|
||||
return if @model.isMini()
|
||||
if @model.isMini()
|
||||
# Mini editors have no gutter decorations.
|
||||
# We clear instead of reassigning to preserve the reference.
|
||||
@clearAllCustomGutterDecorations()
|
||||
|
||||
for gutter in @model.getGutters()
|
||||
gutterName = gutter.name
|
||||
@customGutterDecorations[gutterName] = {}
|
||||
gutterDecorations = @customGutterDecorations[gutterName]
|
||||
if not gutterDecorations
|
||||
@customGutterDecorations[gutterName] = {}
|
||||
else
|
||||
# Clear the gutter decorations; they are rebuilt.
|
||||
# We clear instead of reassigning to preserve the reference.
|
||||
@clearDecorationsForCustomGutterName(gutterName)
|
||||
return if not @gutterIsVisible(gutter)
|
||||
|
||||
relevantDecorations = @customGutterDecorationsInRange(gutterName, @startRow, @endRow - 1)
|
||||
@@ -490,6 +498,18 @@ class TextEditorPresenter
|
||||
item: decoration.getProperties().item
|
||||
class: decoration.getProperties().class
|
||||
|
||||
clearAllCustomGutterDecorations: ->
|
||||
allGutterNames = Object.keys(@customGutterDecorations)
|
||||
for gutterName in allGutterNames
|
||||
@clearDecorationsForCustomGutterName(gutterName)
|
||||
|
||||
clearDecorationsForCustomGutterName: (gutterName) ->
|
||||
gutterDecorations = @customGutterDecorations[gutterName]
|
||||
if gutterDecorations
|
||||
allDecorationIds = Object.keys(gutterDecorations)
|
||||
for decorationId in allDecorationIds
|
||||
delete gutterDecorations[decorationId]
|
||||
|
||||
gutterIsVisible: (gutterModel) ->
|
||||
isVisible = gutterModel.isVisible()
|
||||
if gutterModel.name is 'line-number'
|
||||
|
||||
Reference in New Issue
Block a user