Return an update promise in TextEditor.prototype.update()

This commit is contained in:
Antonio Scandurra
2016-07-08 09:42:08 +02:00
parent f6176c6dda
commit 811ab26f61
2 changed files with 22 additions and 11 deletions

View File

@@ -96,23 +96,29 @@ describe "TextEditor", ->
describe ".update()", ->
it "updates the editor with the supplied config parameters", ->
element = editor.element # force element initialization
atom.config.set('editor.showInvisibles', true)
editor.onDidChange(changeSpy = jasmine.createSpy('onDidChange'))
editor.update({
updatePromise = editor.update({
tabLength: 6, softTabs: false, softWrapped: true, editorWidthInChars: 40,
ignoreInvisibles: true, mini: false, lineNumberGutterVisible: false, scrollPastEnd: true,
autoHeight: false
})
expect(changeSpy.callCount).toBe(1)
expect(editor.getTabLength()).toBe(6)
expect(editor.getSoftTabs()).toBe(false)
expect(editor.isSoftWrapped()).toBe(true)
expect(editor.getEditorWidthInChars()).toBe(40)
expect(editor.getInvisibles()).toEqual({})
expect(editor.isMini()).toBe(false)
expect(editor.isLineNumberGutterVisible()).toBe(false)
expect(editor.getScrollPastEnd()).toBe(true)
expect(editor.getAutoHeight()).toBe(false)
waitsForPromise ->
updatePromise
runs ->
expect(changeSpy.callCount).toBe(1)
expect(editor.getTabLength()).toBe(6)
expect(editor.getSoftTabs()).toBe(false)
expect(editor.isSoftWrapped()).toBe(true)
expect(editor.getEditorWidthInChars()).toBe(40)
expect(editor.getInvisibles()).toEqual({})
expect(editor.isMini()).toBe(false)
expect(editor.isLineNumberGutterVisible()).toBe(false)
expect(editor.getScrollPastEnd()).toBe(true)
expect(editor.getAutoHeight()).toBe(false)
describe "config defaults", ->
it "uses the `editor.tabLength`, `editor.softWrap`, and `editor.softTabs`, and `core.fileEncoding` config values", ->

View File

@@ -234,6 +234,11 @@ class TextEditor extends Model
if resetDisplayLayer
@resetDisplayLayer()
if @editorElement?
@editorElement.views.getNextUpdatePromise()
else
Promise.resolve()
serialize: ->
tokenizedBufferState = @tokenizedBuffer.serialize()