Mark text editors as being registered.

This commit is contained in:
joshaber 2016-05-02 11:32:29 -04:00
parent b7c6850413
commit 9adc822822
2 changed files with 15 additions and 2 deletions

View File

@ -26,8 +26,20 @@ class TextEditorRegistry
# editor is destroyed.
add: (editor) ->
@editors.add(editor)
editor.registered = true
@emitter.emit 'did-add-editor', editor
new Disposable => @editors.delete(editor)
new Disposable => @remove(editor)
# Remove a `TextEditor`.
#
# * `editor` The editor to remove.
#
# Returns a {Boolean} indicating whether the editor was successfully removed.
remove: (editor) ->
removed = @editors.delete(editor)
editor.registered = false
removed
# Invoke the given callback with all the current and future registered
# `TextEditors`.

View File

@ -62,6 +62,7 @@ class TextEditor extends Model
selectionFlashDuration: 500
gutterContainer: null
editorElement: null
registered: false
Object.defineProperty @prototype, "element",
get: -> @getElement()
@ -157,7 +158,7 @@ class TextEditor extends Model
firstVisibleScreenColumn: @getFirstVisibleScreenColumn()
displayBuffer: @displayBuffer.serialize()
selectionsMarkerLayerId: @selectionsMarkerLayer.id
registered: atom.textEditors.editors.has this
registered: @registered
subscribeToBuffer: ->
@buffer.retain()