mirror of
https://github.com/atom/atom.git
synced 2026-02-14 08:35:11 -05:00
Return an update promise in TextEditor.prototype.update()
This commit is contained in:
@@ -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", ->
|
||||
|
||||
@@ -234,6 +234,11 @@ class TextEditor extends Model
|
||||
if resetDisplayLayer
|
||||
@resetDisplayLayer()
|
||||
|
||||
if @editorElement?
|
||||
@editorElement.views.getNextUpdatePromise()
|
||||
else
|
||||
Promise.resolve()
|
||||
|
||||
serialize: ->
|
||||
tokenizedBufferState = @tokenizedBuffer.serialize()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user