mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-07 23:59:22 +03:00
Rename RootView.open to RootView.openSync
This commit is contained in:
parent
c766ddf5e6
commit
b0e9b4b81f
@ -84,7 +84,7 @@ describe "the `atom` global", ->
|
||||
expect(mainModule.activate).toHaveBeenCalled()
|
||||
|
||||
it "triggers the activation event on all handlers registered during activation", ->
|
||||
rootView.open()
|
||||
rootView.openSync()
|
||||
editor = rootView.getActiveView()
|
||||
eventHandler = jasmine.createSpy("activation-event")
|
||||
editor.command 'activation-event', eventHandler
|
||||
|
@ -2672,7 +2672,7 @@ describe "Editor", ->
|
||||
describe "when the editor's text is changed", ->
|
||||
it "redraws the editor when it is next shown", ->
|
||||
window.rootView = new RootView
|
||||
rootView.open('sample.js')
|
||||
rootView.openSync('sample.js')
|
||||
rootView.attachToDom()
|
||||
editor = rootView.getActiveView()
|
||||
|
||||
@ -2726,7 +2726,7 @@ describe "Editor", ->
|
||||
describe "when the editor is removed", ->
|
||||
it "fires a editor:will-be-removed event", ->
|
||||
window.rootView = new RootView
|
||||
rootView.open('sample.js')
|
||||
rootView.openSync('sample.js')
|
||||
rootView.attachToDom()
|
||||
editor = rootView.getActiveView()
|
||||
|
||||
|
@ -11,7 +11,7 @@ describe "RootView", ->
|
||||
pathToOpen = project.resolve('a')
|
||||
window.rootView = new RootView
|
||||
rootView.enableKeymap()
|
||||
rootView.open(pathToOpen)
|
||||
rootView.openSync(pathToOpen)
|
||||
rootView.focus()
|
||||
|
||||
describe "@deserialize()", ->
|
||||
@ -29,7 +29,7 @@ describe "RootView", ->
|
||||
describe "when the serialized RootView has an unsaved buffer", ->
|
||||
it "constructs the view with the same panes", ->
|
||||
rootView.attachToDom()
|
||||
rootView.open()
|
||||
rootView.openSync()
|
||||
editor1 = rootView.getActiveView()
|
||||
buffer = editor1.getBuffer()
|
||||
editor1.splitRight()
|
||||
@ -149,7 +149,7 @@ describe "RootView", ->
|
||||
|
||||
describe "when the project has a path", ->
|
||||
beforeEach ->
|
||||
rootView.open('b')
|
||||
rootView.openSync('b')
|
||||
|
||||
describe "when there is an active pane item", ->
|
||||
it "sets the title to the pane item's title plus the project path", ->
|
||||
@ -215,27 +215,27 @@ describe "RootView", ->
|
||||
|
||||
describe "when called with no path", ->
|
||||
it "creates a empty edit session as an item on a new pane, and focuses the pane", ->
|
||||
editSession = rootView.open()
|
||||
editSession = rootView.openSync()
|
||||
expect(rootView.getActivePane().activeItem).toBe editSession
|
||||
expect(editSession.getPath()).toBeUndefined()
|
||||
expect(rootView.getActivePane().focus).toHaveBeenCalled()
|
||||
|
||||
it "can create multiple empty edit sessions as an item on a new pane", ->
|
||||
editSession = rootView.open()
|
||||
editSession2 = rootView.open()
|
||||
editSession = rootView.openSync()
|
||||
editSession2 = rootView.openSync()
|
||||
expect(rootView.getActivePane().getItems().length).toBe 2
|
||||
expect(editSession).not.toBe editSession2
|
||||
|
||||
describe "when called with a path", ->
|
||||
it "creates an edit session for the given path as an item on a new pane, and focuses the pane", ->
|
||||
editSession = rootView.open('b')
|
||||
editSession = rootView.openSync('b')
|
||||
expect(rootView.getActivePane().activeItem).toBe editSession
|
||||
expect(editSession.getPath()).toBe require.resolve('./fixtures/dir/b')
|
||||
expect(rootView.getActivePane().focus).toHaveBeenCalled()
|
||||
|
||||
describe "when the changeFocus option is false", ->
|
||||
it "does not focus the new pane", ->
|
||||
editSession = rootView.open('b', changeFocus: false)
|
||||
editSession = rootView.openSync('b', changeFocus: false)
|
||||
expect(rootView.getActivePane().focus).not.toHaveBeenCalled()
|
||||
|
||||
describe "when there is an active pane", ->
|
||||
@ -247,7 +247,7 @@ describe "RootView", ->
|
||||
|
||||
describe "when called with no path", ->
|
||||
it "opens an edit session with an empty buffer as an item in the active pane and focuses it", ->
|
||||
editSession = rootView.open()
|
||||
editSession = rootView.openSync()
|
||||
expect(activePane.getItems().length).toBe initialItemCount + 1
|
||||
expect(activePane.activeItem).toBe editSession
|
||||
expect(editSession.getPath()).toBeUndefined()
|
||||
@ -258,11 +258,11 @@ describe "RootView", ->
|
||||
it "shows the existing edit session in the pane", ->
|
||||
previousEditSession = activePane.activeItem
|
||||
|
||||
editSession = rootView.open('b')
|
||||
editSession = rootView.openSync('b')
|
||||
expect(activePane.activeItem).toBe editSession
|
||||
expect(editSession).not.toBe previousEditSession
|
||||
|
||||
editSession = rootView.open(previousEditSession.getPath())
|
||||
editSession = rootView.openSync(previousEditSession.getPath())
|
||||
expect(editSession).toBe previousEditSession
|
||||
expect(activePane.activeItem).toBe editSession
|
||||
|
||||
@ -270,14 +270,14 @@ describe "RootView", ->
|
||||
|
||||
describe "when the active pane does not have an edit session item for the path being opened", ->
|
||||
it "creates a new edit session for the given path in the active editor", ->
|
||||
editSession = rootView.open('b')
|
||||
editSession = rootView.openSync('b')
|
||||
expect(activePane.items.length).toBe 2
|
||||
expect(activePane.activeItem).toBe editSession
|
||||
expect(activePane.focus).toHaveBeenCalled()
|
||||
|
||||
describe "when the changeFocus option is false", ->
|
||||
it "does not focus the active pane", ->
|
||||
editSession = rootView.open('b', changeFocus: false)
|
||||
editSession = rootView.openSync('b', changeFocus: false)
|
||||
expect(activePane.focus).not.toHaveBeenCalled()
|
||||
|
||||
describe ".openAsync(filePath)", ->
|
||||
@ -451,6 +451,7 @@ describe "RootView", ->
|
||||
rootView.attachToDom()
|
||||
|
||||
it "invokes the callback for existing buffer", ->
|
||||
count = 0
|
||||
count = 0
|
||||
callbackBuffer = null
|
||||
callback = (buffer) ->
|
||||
@ -470,6 +471,6 @@ describe "RootView", ->
|
||||
rootView.eachBuffer(callback)
|
||||
count = 0
|
||||
callbackBuffer = null
|
||||
rootView.open(require.resolve('./fixtures/sample.txt'))
|
||||
rootView.openSync(require.resolve('./fixtures/sample.txt'))
|
||||
expect(count).toBe 1
|
||||
expect(callbackBuffer).toBe rootView.getActiveView().getBuffer()
|
||||
|
@ -56,7 +56,7 @@ describe "Window", ->
|
||||
it "prompts user to save and and calls rootView.confirmClose", ->
|
||||
spyOn(rootView, 'confirmClose').andCallThrough()
|
||||
spyOn(atom, "confirmSync").andReturn(2)
|
||||
editSession = rootView.open("sample.js")
|
||||
editSession = rootView.openSync("sample.js")
|
||||
editSession.insertText("I look different, I feel different.")
|
||||
$(window).trigger 'beforeunload'
|
||||
expect(rootView.confirmClose).toHaveBeenCalled()
|
||||
@ -64,14 +64,14 @@ describe "Window", ->
|
||||
|
||||
it "prompts user to save and handler returns true if don't save", ->
|
||||
spyOn(atom, "confirmSync").andReturn(2)
|
||||
editSession = rootView.open("sample.js")
|
||||
editSession = rootView.openSync("sample.js")
|
||||
editSession.insertText("I look different, I feel different.")
|
||||
expect(window.onbeforeunload(new Event('beforeunload'))).toBeTruthy()
|
||||
expect(atom.confirmSync).toHaveBeenCalled()
|
||||
|
||||
it "prompts user to save and handler returns false if dialog is canceled", ->
|
||||
spyOn(atom, "confirmSync").andReturn(1)
|
||||
editSession = rootView.open("sample.js")
|
||||
editSession = rootView.openSync("sample.js")
|
||||
editSession.insertText("I look different, I feel different.")
|
||||
expect(window.onbeforeunload(new Event('beforeunload'))).toBeFalsy()
|
||||
expect(atom.confirmSync).toHaveBeenCalled()
|
||||
@ -88,7 +88,7 @@ describe "Window", ->
|
||||
expect(atom.saveWindowState).toHaveBeenCalled()
|
||||
|
||||
it "unsubscribes from all buffers", ->
|
||||
rootView.open('sample.js')
|
||||
rootView.openSync('sample.js')
|
||||
buffer = rootView.getActivePaneItem().buffer
|
||||
rootView.getActivePane().splitRight()
|
||||
expect(window.rootView.find('.editor').length).toBe 2
|
||||
|
@ -171,7 +171,7 @@ class RootView extends View
|
||||
# + initialLine: The buffer line number to open to.
|
||||
#
|
||||
# Returns a promise that resolves to the {EditSession} for the file URI.
|
||||
openAsync: (filePath, options={}) ->
|
||||
open: (filePath, options={}) ->
|
||||
filePath = project.resolve(filePath)
|
||||
initialLine = options.initialLine
|
||||
activePane = @getActivePane()
|
||||
@ -192,8 +192,8 @@ class RootView extends View
|
||||
activePane.focus()
|
||||
editSession
|
||||
|
||||
# Private: DEPRECATED Synchronously Opens a given a filepath in Atom.
|
||||
open: (filePath, options = {}) ->
|
||||
# Private: Only used in specs
|
||||
openSync: (filePath, options = {}) ->
|
||||
changeFocus = options.changeFocus ? true
|
||||
initialLine = options.initialLine
|
||||
filePath = project.relativize(filePath)
|
||||
|
@ -25,7 +25,7 @@ class WindowEventHandler
|
||||
|
||||
@subscribe $(window), 'window:open-path', (event, {pathToOpen, initialLine}) ->
|
||||
unless fsUtils.isDirectorySync(pathToOpen)
|
||||
atom.rootView?.openAsync(pathToOpen, {initialLine})
|
||||
atom.rootView?.open(pathToOpen, {initialLine})
|
||||
|
||||
@subscribe $(window), 'beforeunload', =>
|
||||
confirmed = atom.rootView?.confirmClose()
|
||||
|
Loading…
Reference in New Issue
Block a user