mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Unsubscribe from Buffer when an Editor is removed from the DOM.
This commit is contained in:
@@ -896,6 +896,19 @@ describe "Editor", ->
|
||||
editor.attachToDom()
|
||||
expect(editor).toMatchSelector ":has(:focus)"
|
||||
|
||||
it "unsubscribes from the buffer when it is removed from the dom", ->
|
||||
buffer = new Buffer
|
||||
previousSubscriptionCount = buffer.subscriptionCount()
|
||||
|
||||
editor.attachToDom()
|
||||
editor.setBuffer(buffer)
|
||||
|
||||
expect(buffer.subscriptionCount()).toBeGreaterThan previousSubscriptionCount
|
||||
expect($('.editor')).toExist()
|
||||
editor.remove()
|
||||
expect(buffer.subscriptionCount()).toBe previousSubscriptionCount
|
||||
expect($('.editor')).not.toExist()
|
||||
|
||||
describe "when the editor recieves focused", ->
|
||||
it "focuses the hidden input", ->
|
||||
editor.attachToDom()
|
||||
|
||||
@@ -165,8 +165,7 @@ class Editor extends View
|
||||
setBuffer: (buffer) ->
|
||||
if @buffer
|
||||
@saveEditSession()
|
||||
@buffer.off ".editor#{@id}"
|
||||
@renderer.destroy()
|
||||
@unsubscribeFromBuffer()
|
||||
|
||||
@buffer = buffer
|
||||
|
||||
@@ -397,3 +396,11 @@ class Editor extends View
|
||||
|
||||
logLines: ->
|
||||
@renderer.logLines()
|
||||
|
||||
remove: ->
|
||||
@unsubscribeFromBuffer()
|
||||
super
|
||||
|
||||
unsubscribeFromBuffer: ->
|
||||
@buffer.off ".editor#{@id}"
|
||||
@renderer.destroy()
|
||||
|
||||
Reference in New Issue
Block a user