mirror of
https://github.com/atom/atom.git
synced 2026-02-03 11:14:59 -05:00
✅ Ensure terminate handler is invoked only once
This commit is contained in:
@@ -5835,3 +5835,22 @@ describe "TextEditor", ->
|
||||
|
||||
expect(editor1.isPending()).toBe false
|
||||
expect(events).toEqual [editor1]
|
||||
|
||||
it "only calls terminate handler once when text is modified twice", ->
|
||||
editor1.insertText('Some text')
|
||||
advanceClock(500)
|
||||
|
||||
editor1.save()
|
||||
|
||||
editor1.insertText('More text')
|
||||
advanceClock(500)
|
||||
|
||||
expect(editor1.isPending()).toBe false
|
||||
expect(events).toEqual [editor1]
|
||||
|
||||
it "only calls terminate handler once when terminatePendingState is called twice", ->
|
||||
editor1.terminatePendingState()
|
||||
editor1.terminatePendingState()
|
||||
|
||||
expect(editor1.isPending()).toBe false
|
||||
expect(events).toEqual [editor1]
|
||||
|
||||
@@ -576,6 +576,7 @@ class TextEditor extends Model
|
||||
@emitter.on 'did-terminate-pending-state', callback
|
||||
|
||||
terminatePendingState: ->
|
||||
return if not @pending
|
||||
@pending = false
|
||||
@emitter.emit 'did-terminate-pending-state', this
|
||||
|
||||
|
||||
Reference in New Issue
Block a user